summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTheron Luhn <theron@luhn.com>2019-07-21 09:20:44 -0700
committerTheron Luhn <theron@luhn.com>2019-07-21 09:20:44 -0700
commitd2d20b92158088e7d646393733092e67120058f0 (patch)
tree74fd87877de8e43163b494bfc8be8167436ed02c /src
parent09960927167f80bb405da52c96775241c84a8682 (diff)
downloadpyramid-d2d20b92158088e7d646393733092e67120058f0.tar.gz
pyramid-d2d20b92158088e7d646393733092e67120058f0.tar.bz2
pyramid-d2d20b92158088e7d646393733092e67120058f0.zip
Un-deprecate authenticated_userid.
Diffstat (limited to 'src')
-rw-r--r--src/pyramid/interfaces.py4
-rw-r--r--src/pyramid/security.py52
2 files changed, 28 insertions, 28 deletions
diff --git a/src/pyramid/interfaces.py b/src/pyramid/interfaces.py
index 06ab1c32e..d97c3811b 100644
--- a/src/pyramid/interfaces.py
+++ b/src/pyramid/interfaces.py
@@ -485,8 +485,8 @@ class IViewMapperFactory(Interface):
class ISecurityPolicy(Interface):
def identify(request):
""" Return an object identifying a trusted and verified user. This
- object may be anything, but should implement a ``__str__`` method for
- logging and debugging purposes.
+ object may be anything, but should implement a ``__str__`` method that
+ outputs a corresponding :term:`userid`.
"""
diff --git a/src/pyramid/security.py b/src/pyramid/security.py
index 64e840801..08c36b457 100644
--- a/src/pyramid/security.py
+++ b/src/pyramid/security.py
@@ -306,6 +306,28 @@ class SecurityAPIMixin(object):
return None
return policy.identify(self)
+ @property
+ def authenticated_userid(self):
+ """
+ Return the :term:`userid` of the currently authenticated user or
+ ``None`` if there is no :term:`security policy` in effect or there is
+ no currently authenticated user.
+
+ .. versionchanged:: 2.0
+
+ When using the new security system, this property outputs the
+ string representation of the :term:`identity`.
+
+ """
+ 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 str(security.identify(self))
+ else:
+ return None
+
def has_permission(self, permission, context=None):
""" Given a permission and an optional context, returns an instance of
:data:`pyramid.security.Allowed` if the permission is granted to this
@@ -337,36 +359,14 @@ class SecurityAPIMixin(object):
class AuthenticationAPIMixin(object):
@property
- def authenticated_userid(self):
- """
- .. deprecated:: 2.0
-
- ``authenticated_userid`` has been replaced by
- :attr:`authenticated_identity` in the new security system. See
- :ref:`upgrading_auth` for more information.
-
- Return the userid of the currently authenticated user or
- ``None`` if there is no :term:`authentication policy` in effect or
- there is no currently authenticated user.
-
- """
- 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 str(security.identify(self))
- else:
- return None
-
- @property
def unauthenticated_userid(self):
"""
.. deprecated:: 2.0
- ``unauthenticated_userid`` has been replaced by
- :attr:`authenticated_identity` in the new security system. See
- :ref:`upgrading_auth` for more information.
+ ``unauthenticated_userid`` does not have an equivalent in the new
+ security system. Use :attr:`.authenticated_userid` or
+ :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