Skip to content

Instantly share code, notes, and snippets.

@SlyDen
Created January 28, 2016 11:25
Show Gist options
  • Save SlyDen/7965394a9674af2fb5a0 to your computer and use it in GitHub Desktop.
Save SlyDen/7965394a9674af2fb5a0 to your computer and use it in GitHub Desktop.
from pyramid.authentication import AuthTktAuthenticationPolicy
class MyAuthenticationPolicy(AuthTktAuthenticationPolicy):
def authenticated_userid(self, request):
userid = self.unauthenticated_userid(request)
if userid:
if request.verify_userid_is_still_valid(userid):
return userid
def effective_principals(self, request):
principals = [Everyone]
userid = self.authenticated_userid(request)
if userid:
principals += [Authenticated, str(userid)]
return principals
authn_policy = MyAuthenticationPolicy()
config.set_authentication_policy(authn_policy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment