diff options
| author | Theron Luhn <theron@luhn.com> | 2019-03-02 11:26:37 -0800 |
|---|---|---|
| committer | Theron Luhn <theron@luhn.com> | 2019-03-03 08:36:31 -0800 |
| commit | 140fdbb54c467159313ede564dd3ad4077e30f20 (patch) | |
| tree | 983ff140220feef7df23d48be1555cc8862cd164 /src | |
| parent | aae1c513c0a940c1c31c97b4d79fec3d09cbd01e (diff) | |
| download | pyramid-140fdbb54c467159313ede564dd3ad4077e30f20.tar.gz pyramid-140fdbb54c467159313ede564dd3ad4077e30f20.tar.bz2 pyramid-140fdbb54c467159313ede564dd3ad4077e30f20.zip | |
Implement bw-compat authenticated_userid and unauthenticated_userid
Diffstat (limited to 'src')
| -rw-r--r-- | src/pyramid/request.py | 4 | ||||
| -rw-r--r-- | src/pyramid/security.py | 20 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/pyramid/request.py b/src/pyramid/request.py index 726f485e7..bb0dcaa2b 100644 --- a/src/pyramid/request.py +++ b/src/pyramid/request.py @@ -16,7 +16,9 @@ from pyramid.decorator import reify from pyramid.i18n import LocalizerRequestMixin from pyramid.response import Response, _get_response_factory from pyramid.security import ( - SecurityAPIMixin, AuthenticationAPIMixin, AuthorizationAPIMixin, + SecurityAPIMixin, + AuthenticationAPIMixin, + AuthorizationAPIMixin, ) from pyramid.url import URLMethodsMixin from pyramid.util import ( diff --git a/src/pyramid/security.py b/src/pyramid/security.py index efc0c193c..66e314f79 100644 --- a/src/pyramid/security.py +++ b/src/pyramid/security.py @@ -312,10 +312,14 @@ class AuthenticationAPIMixin(object): Use ``request.identity`` instead. """ - policy = _get_authentication_policy(self) - if policy is None: + authn = _get_authentication_policy(self) + security = _get_security_policy(self) + if authn is not None: + return authn.authenticated_userid(self) + elif security is not None: + return security.identify(self) + else: return None - return policy.authenticated_userid(self) @property def unauthenticated_userid(self): @@ -332,10 +336,14 @@ class AuthenticationAPIMixin(object): Use ``request.identity`` instead. """ - policy = _get_authentication_policy(self) - if policy is None: + authn = _get_authentication_policy(self) + security = _get_security_policy(self) + if authn is not None: + return authn.unauthenticated_userid(self) + elif security is not None: + return security.identify(self) + else: return None - return policy.unauthenticated_userid(self) @property def effective_principals(self): |
