Ticket #130: paste.diff

File paste.diff, 2.0 KB (added by martinpaljak, 6 years ago)

Patch with docstring addition

  • paste/auth/cookie.py

     
    220220            or list of environment keys will work.  However, be 
    221221            careful, as the total saved size is limited to around 3k. 
    222222 
     223        ``universal`` 
     224 
     225            Set this to True if you want the cookie to be usable for both 
     226            HTTPS and normal HTTP connections. This is useful if you first 
     227            want to set the authentication cookie via HTTPS but want to use 
     228            it on non-HTTPS parts of the site as well. This controls the 
     229            'Secure' flag of the cookie. 
     230 
    223231        ``signer`` 
    224232 
    225233            This is the signer object used to create the actual cookie 
     
    237245    environ_class = AuthCookieEnviron 
    238246 
    239247    def __init__(self, application, cookie_name=None, scanlist=None, 
    240                  signer=None, secret=None, timeout=None, maxlen=None): 
     248                 signer=None, secret=None, timeout=None, maxlen=None, universal=False): 
    241249        if not signer: 
    242250            signer = self.signer_class(secret, timeout, maxlen) 
    243251        self.signer = signer 
    244252        self.scanlist = scanlist or ('REMOTE_USER','REMOTE_SESSION') 
    245253        self.application = application 
    246254        self.cookie_name = cookie_name or self.cookie_name 
     255        self.universal = universal 
    247256 
    248257    def __call__(self, environ, start_response): 
    249258        if self.environ_name in environ: 
     
    291300                content = ";".join(content) 
    292301                content = self.signer.sign(content) 
    293302                cookie = '%s=%s; Path=/;' % (self.cookie_name, content) 
    294                 if 'https' == environ['wsgi.url_scheme']: 
     303                if not self.universal and 'https' == environ['wsgi.url_scheme']: 
    295304                    cookie += ' secure;' 
    296305                response_headers.append(('Set-Cookie', cookie)) 
    297306            return start_response(status, response_headers, exc_info)