summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2020-11-01 18:15:49 -0600
committerGitHub <noreply@github.com>2020-11-01 18:15:49 -0600
commit68a6cb1dba7944f1e214ca62ce700e3f7ddf618d (patch)
treea1d646c7feefb9a28347b9826829d4ad59730c46 /src
parentc6772eadc18056b5eed90f6a694e53579ba403a4 (diff)
parent139462d451a1c35679b464690953333dd95389a1 (diff)
downloadpyramid-68a6cb1dba7944f1e214ca62ce700e3f7ddf618d.tar.gz
pyramid-68a6cb1dba7944f1e214ca62ce700e3f7ddf618d.tar.bz2
pyramid-68a6cb1dba7944f1e214ca62ce700e3f7ddf618d.zip
Merge pull request #3620 from luhn/identity-rename
Rename `ISecurityPolicy.authenticated_identity` to `identity`
Diffstat (limited to 'src')
-rw-r--r--src/pyramid/config/testing.py7
-rw-r--r--src/pyramid/interfaces.py10
-rw-r--r--src/pyramid/request.py2
-rw-r--r--src/pyramid/security.py12
-rw-r--r--src/pyramid/testing.py6
5 files changed, 18 insertions, 19 deletions
diff --git a/src/pyramid/config/testing.py b/src/pyramid/config/testing.py
index 75a2d1c64..4ff858d89 100644
--- a/src/pyramid/config/testing.py
+++ b/src/pyramid/config/testing.py
@@ -32,10 +32,9 @@ class TestingConfiguratorMixin:
:attr:`pyramid.request.Request.authenticated_userid` will have this
value as well.
:type userid: str
- :param identity: If provided, the policy's ``authenticated_identity``
- method will return this value. As a result,
- :attr:`pyramid.request.Request.authenticated_identity`` will have
- this value.
+ :param identity: If provided, the policy's ``identity`` method will
+ return this value. As a result,
+ :attr:`pyramid.request.Request.identity`` will have this value.
:type identity: object
:param permissive: If true, the policy will allow access to any user
for any permission. If false, the policy will deny all access.
diff --git a/src/pyramid/interfaces.py b/src/pyramid/interfaces.py
index ffac7f641..0b7a07040 100644
--- a/src/pyramid/interfaces.py
+++ b/src/pyramid/interfaces.py
@@ -113,10 +113,10 @@ class IResponse(Interface):
"""Return a new app_iter built from the response app_iter that
serves up only the given start:stop range."""
- authenticated_identity = Attribute(
- """An object representing the authenticated user, as determined by
- the security policy in use, or ``None`` for unauthenticated requests.
- The object's class and meaning is defined by the security policy."""
+ identity = Attribute(
+ """An object containing authentication information related to the
+ current request. The object's type and meaning is defined by the
+ configured security policy."""
)
authenticated_userid = Attribute(
@@ -498,7 +498,7 @@ class IViewMapperFactory(Interface):
class ISecurityPolicy(Interface):
- def authenticated_identity(request):
+ def identity(request):
"""Return the :term:`identity` of the current user. The object can be
of any shape, such as a simple ID string or an ORM object.
"""
diff --git a/src/pyramid/request.py b/src/pyramid/request.py
index e5cfb37b8..c111bc62b 100644
--- a/src/pyramid/request.py
+++ b/src/pyramid/request.py
@@ -377,7 +377,7 @@ class RequestLocalCache:
result = ... # do some expensive computations
return result
- def authenticated_identity(self, request):
+ def identity(self, request):
return self.identity_cache.get_or_create(request)
The cache maintains a weakref to each request and will release the cached
diff --git a/src/pyramid/security.py b/src/pyramid/security.py
index cbab0a0f2..9cdafaf6f 100644
--- a/src/pyramid/security.py
+++ b/src/pyramid/security.py
@@ -215,7 +215,7 @@ class SecurityAPIMixin:
""" Mixin for Request class providing auth-related properties. """
@property
- def authenticated_identity(self):
+ def identity(self):
"""
Return an opaque object identifying the current user or ``None`` if no
user is authenticated or there is no :term:`security policy` in effect.
@@ -224,7 +224,7 @@ class SecurityAPIMixin:
policy = _get_security_policy(self)
if policy is None:
return None
- return policy.authenticated_identity(self)
+ return policy.identity(self)
@property
def authenticated_userid(self):
@@ -247,7 +247,7 @@ class SecurityAPIMixin:
@property
def is_authenticated(self):
"""Return ``True`` if a user is authenticated for this request."""
- return self.authenticated_identity is not None
+ return self.authenticated_userid is not None
def has_permission(self, permission, context=None):
"""Given a permission and an optional context, returns an instance of
@@ -287,8 +287,8 @@ class AuthenticationAPIMixin:
``unauthenticated_userid`` does not have an equivalent in the new
security system. Use :attr:`.authenticated_userid` or
- :attr:`.authenticated_identity` instead.
- See :ref:`upgrading_auth` for more information.
+ :attr:`.identity` instead. See :ref:`upgrading_auth` for more
+ information.
Return an object which represents the *claimed* (not verified) user
id of the credentials present in the request. ``None`` if there is no
@@ -362,7 +362,7 @@ class LegacySecurityPolicy:
def _get_authz_policy(self, request):
return request.registry.getUtility(IAuthorizationPolicy)
- def authenticated_identity(self, request):
+ def identity(self, request):
return self.authenticated_userid(request)
def authenticated_userid(self, request):
diff --git a/src/pyramid/testing.py b/src/pyramid/testing.py
index ddfe2a660..621a69d4b 100644
--- a/src/pyramid/testing.py
+++ b/src/pyramid/testing.py
@@ -42,7 +42,7 @@ class DummySecurityPolicy:
forget_result=None,
):
self.userid = userid
- self.identity = identity
+ self._identity = identity
self.permissive = permissive
if remember_result is None:
remember_result = []
@@ -51,8 +51,8 @@ class DummySecurityPolicy:
self.remember_result = remember_result
self.forget_result = forget_result
- def authenticated_identity(self, request):
- return self.identity
+ def identity(self, request):
+ return self._identity
def authenticated_userid(self, request):
return self.userid