summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheron Luhn <theron@luhn.com>2019-04-15 19:04:35 -0700
committerTheron Luhn <theron@luhn.com>2019-04-15 19:04:35 -0700
commit47f8935bb5423718ec293bba4709307be7d2f51c (patch)
tree2ef48e54dfbf82c9aa52a7fe1ef1fb6cac1ffb48
parent8536f3ab834b4da7cc24a88855a3f883929b5b1e (diff)
downloadpyramid-47f8935bb5423718ec293bba4709307be7d2f51c.tar.gz
pyramid-47f8935bb5423718ec293bba4709307be7d2f51c.tar.bz2
pyramid-47f8935bb5423718ec293bba4709307be7d2f51c.zip
Stringify identity in legacy authenticated_userid.
-rw-r--r--src/pyramid/security.py2
-rw-r--r--tests/test_security.py5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/pyramid/security.py b/src/pyramid/security.py
index e28ce0f1c..a55320ce6 100644
--- a/src/pyramid/security.py
+++ b/src/pyramid/security.py
@@ -355,7 +355,7 @@ class AuthenticationAPIMixin(object):
if authn is not None:
return authn.authenticated_userid(self)
elif security is not None:
- return security.identify(self)
+ return str(security.identify(self))
else:
return None
diff --git a/tests/test_security.py b/tests/test_security.py
index b66632baa..97aec42c6 100644
--- a/tests/test_security.py
+++ b/tests/test_security.py
@@ -357,8 +357,9 @@ class TestAuthenticatedUserId(unittest.TestCase):
def test_with_security_policy(self):
request = _makeRequest()
- _registerSecurityPolicy(request.registry, 'yo')
- self.assertEqual(request.authenticated_userid, 'yo')
+ # Ensure the identity is stringified.
+ _registerSecurityPolicy(request.registry, 123)
+ self.assertEqual(request.authenticated_userid, '123')
def test_with_authentication_policy_no_reg_on_request(self):
from pyramid.threadlocal import get_current_registry