Handle '__setauthcookie'
'__setauthcookie' is a form parameter added by the 'rememberme' cube.
If present and equals to '1', the cookie max_age will be set to 7 days instead
of being a session cookie.
To make sure the auth cookie is renewed, the reissue_time is set to 1h.
--- a/pyramid_cubicweb/defaults.py Thu Sep 18 15:07:02 2014 +0200
+++ b/pyramid_cubicweb/defaults.py Thu Sep 18 16:51:55 2014 +0200
@@ -28,7 +28,8 @@
config.set_authentication_policy(
AuthTktAuthenticationPolicy(
- secret, callback=get_principals, hashalg='sha512'))
+ secret, callback=get_principals, hashalg='sha512',
+ reissue_time=3600))
config.set_authorization_policy(ACLAuthorizationPolicy())
config.include('pyramid_cubicweb.login')
--- a/pyramid_cubicweb/login.py Thu Sep 18 15:07:02 2014 +0200
+++ b/pyramid_cubicweb/login.py Thu Sep 18 16:51:55 2014 +0200
@@ -33,7 +33,10 @@
del request.cw_request.post['__password']
return login_form(request)
- headers = security.remember(request, user_eid)
+ max_age = None
+ if request.params.get('__setauthcookie') == '1':
+ max_age = '604800'
+ headers = security.remember(request, user_eid, max_age=max_age)
new_path = request.params.get('postlogin_path', '/')