Ticket #130: paste.diff
| File paste.diff, 2.0 KB (added by martinpaljak, 6 years ago) |
|---|
-
paste/auth/cookie.py
220 220 or list of environment keys will work. However, be 221 221 careful, as the total saved size is limited to around 3k. 222 222 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 223 231 ``signer`` 224 232 225 233 This is the signer object used to create the actual cookie … … 237 245 environ_class = AuthCookieEnviron 238 246 239 247 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): 241 249 if not signer: 242 250 signer = self.signer_class(secret, timeout, maxlen) 243 251 self.signer = signer 244 252 self.scanlist = scanlist or ('REMOTE_USER','REMOTE_SESSION') 245 253 self.application = application 246 254 self.cookie_name = cookie_name or self.cookie_name 255 self.universal = universal 247 256 248 257 def __call__(self, environ, start_response): 249 258 if self.environ_name in environ: … … 291 300 content = ";".join(content) 292 301 content = self.signer.sign(content) 293 302 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']: 295 304 cookie += ' secure;' 296 305 response_headers.append(('Set-Cookie', cookie)) 297 306 return start_response(status, response_headers, exc_info)
