assembl.auth.util module¶
Sundry utility functions having to do with users or permissions
-
class
assembl.auth.util.
TokenSessionAuthenticationPolicy
(prefix='auth.', callback=None, debug=False)[source]¶ Bases:
pyramid.authentication.SessionAuthenticationPolicy
A session authentication policy that accepts tokens for identity instead of the beaker session’s login.
-
authenticated_userid
(request)[source]¶ Return the authenticated userid or
None
.If no callback is registered, this will be the same as
unauthenticated_userid
.If a
callback
is registered, this will return the userid if and only if the callback returns a value that is notNone
.
-
effective_principals
(request)[source]¶ A list of effective principals derived from request.
This will return a list of principals including, at least,
pyramid.security.Everyone
. If there is no authenticated userid, or thecallback
returnsNone
, this will be the only principal:return [Everyone]
If the
callback
does not returnNone
and an authenticated userid is found, then the principals will includepyramid.security.Authenticated
, theauthenticated_userid
and the list of principals returned by thecallback
:extra_principals = callback(userid, request) return [Everyone, Authenticated, userid] + extra_principals
-
-
class
assembl.auth.util.
UpgradingSessionAuthenticationPolicy
(prefix='auth.', callback=None, debug=False)[source]¶ Bases:
pyramid.authentication.SessionAuthenticationPolicy
A session authentication policy that tells the underlying beaker session whenever the user logs in or out. Allows to have different cookie policies
-
class
assembl.auth.util.
UpgradingTokenSessionAuthenticationPolicy
(prefix='auth.', callback=None, debug=False)[source]¶ Bases:
assembl.auth.util.TokenSessionAuthenticationPolicy
,assembl.auth.util.UpgradingSessionAuthenticationPolicy
Mixing
UpgradingSessionAuthenticationPolicy
andTokenSessionAuthenticationPolicy
.
-
assembl.auth.util.
authentication_callback
(user_id, request)[source]¶ This is how pyramid knows the user’s permissions
-
assembl.auth.util.
discussion_id_from_request
(request)[source]¶ Obtain the discussion_id from the request, possibly without fetching the discussion