# HG changeset patch # User Christophe de Vienne # Date 1411033425 -7200 # Node ID 4d7286f079e1151e9714699493ab4e4108a2ddd2 # Parent bfc1aa1dba30cc2afd632c15c01de6c14e0ec1b5 Use AuthTktAuthenticationPolicy diff -r bfc1aa1dba30 -r 4d7286f079e1 pyramid_cubicweb/defaults.py --- a/pyramid_cubicweb/defaults.py Fri Sep 19 14:26:55 2014 +0200 +++ b/pyramid_cubicweb/defaults.py Thu Sep 18 11:43:45 2014 +0200 @@ -1,4 +1,6 @@ -from pyramid.authentication import SessionAuthenticationPolicy +import warnings + +from pyramid.authentication import AuthTktAuthenticationPolicy from pyramid.authorization import ACLAuthorizationPolicy from pyramid_cubicweb.core import get_principals @@ -7,8 +9,26 @@ def includeme(config): config.include('pyramid_cubicweb.session') + secret = config.registry['cubicweb.config']['pyramid-auth-secret'] + + if not secret: + secret = 'notsosecret' + warnings.warn(''' + + !! WARNING !! !! WARNING !! + + The authentication cookies are signed with a static secret key. + To put your own secret key, edit your all-in-one.conf file + and set the 'pyramid-session-secret' key. + + YOU SHOULD STOP THIS INSTANCE unless your really know what you + are doing !! + + ''') + config.set_authentication_policy( - SessionAuthenticationPolicy(callback=get_principals)) + AuthTktAuthenticationPolicy( + secret, callback=get_principals, hashalg='sha512')) config.set_authorization_policy(ACLAuthorizationPolicy()) config.include('pyramid_cubicweb.login')