diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-23 17:29:03 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-23 17:29:03 +0000 |
| commit | dba59c91418886a6e382adaf0ad3abb6bd013a93 (patch) | |
| tree | ea017da96cf4e2420b2320bdd1d8f249682a6551 /repoze/bfg/authentication.py | |
| parent | 266ec54af7dafc923d4aff1af5b4088d76980434 (diff) | |
| download | pyramid-dba59c91418886a6e382adaf0ad3abb6bd013a93.tar.gz pyramid-dba59c91418886a6e382adaf0ad3abb6bd013a93.tar.bz2 pyramid-dba59c91418886a6e382adaf0ad3abb6bd013a93.zip | |
- The ``callback`` argument of the ``repoze.bfg.authentication``
authentication policies named ``RepozeWho1AuthenticationPolicy``,
``RemoteUserAuthenticationPolicy``, and
``AuthTktAuthenticationPolicy`` now must accept two positional
arguments: the orginal argument accepted by each (userid or
identity) plus a second argument, which will be the current request.
Apologies, this is required to service finding groups when there is
no "global" database connection.
Diffstat (limited to 'repoze/bfg/authentication.py')
| -rw-r--r-- | repoze/bfg/authentication.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/repoze/bfg/authentication.py b/repoze/bfg/authentication.py index 5aca0c110..37f03cf8b 100644 --- a/repoze/bfg/authentication.py +++ b/repoze/bfg/authentication.py @@ -19,7 +19,7 @@ class CallbackAuthenticationPolicy(object): return None if self.callback is None: return userid - if self.callback(userid) is not None: # is not None! + if self.callback(userid, request) is not None: # is not None! return userid def effective_principals(self, request): @@ -30,7 +30,7 @@ class CallbackAuthenticationPolicy(object): if self.callback is None: groups = [] else: - groups = self.callback(userid) + groups = self.callback(userid, request) if groups is None: # is None! return effective_principals effective_principals.append(Authenticated) @@ -54,11 +54,12 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy): ``callback`` - Default: ``None``. A callback passed the repoze.who identity, - expected to return None if the user represented by the - identity doesn't exist or a sequence of group identifiers - (possibly empty) if the user does exist. If ``callback`` is - None, the userid will be assumed to exist with no groups. + Default: ``None``. A callback passed the repoze.who identity + and the request, expected to return None if the user + represented by the identity doesn't exist or a sequence of + group identifiers (possibly empty) if the user does exist. If + ``callback`` is None, the userid will be assumed to exist with + no groups. """ implements(IAuthenticationPolicy) @@ -83,7 +84,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy): return None if self.callback is None: return identity['repoze.who.userid'] - if self.callback(identity) is not None: # is not None! + if self.callback(identity, request) is not None: # is not None! return identity['repoze.who.userid'] def effective_principals(self, request): @@ -94,7 +95,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy): if self.callback is None: groups = [] else: - groups = self.callback(identity) + groups = self.callback(identity, request) if groups is None: # is None! return effective_principals userid = identity['repoze.who.userid'] @@ -132,10 +133,11 @@ class RemoteUserAuthenticationPolicy(CallbackAuthenticationPolicy): ``callback`` - Default: ``None``. A callback passed the userid, expected to return - None if the userid doesn't exist or a sequence of group identifiers - (possibly empty) if the user does exist. If ``callback`` is None, - the userid will be assumed to exist with no groups. + Default: ``None``. A callback passed the userid and the request, + expected to return None if the userid doesn't exist or a sequence + of group identifiers (possibly empty) if the user does exist. + If ``callback`` is None, the userid will be assumed to exist with no + groups. """ implements(IAuthenticationPolicy) |
