Permalink
Browse files

Merge pull request #1254 from rbu/repozewho1-remember-kwargs

Hand RepozeWho1AuthenticationPolicy.remember kwargs to repoze.who (master) #1249
  • Loading branch information...
2 parents e175ffc + 76144df commit 3063246aa418ae2008adb48ab9e5090a88be42d4 @tseaver tseaver committed Mar 3, 2014
Showing with 17 additions and 2 deletions.
  1. +9 −2 pyramid/authentication.py
  2. +8 −0 pyramid/tests/test_authentication.py
@@ -336,12 +336,19 @@ def effective_principals(self, request):
return effective_principals
def remember(self, request, principal, **kw):
- """ Store the ``principal`` as ``repoze.who.userid``."""
+ """ Store the ``principal`` as ``repoze.who.userid``.
+
+ The identity to authenticated to :mod:`repoze.who`
+ will contain the given principal as ``userid``, and
+ provide all keyword arguments as additional identity
+ keys. Useful keys could be ``max_age`` or ``userdata``.
+ """
identifier = self._get_identifier(request)
if identifier is None:
return []
environ = request.environ
- identity = {'repoze.who.userid':principal}
+ identity = kw
+ identity['repoze.who.userid'] = principal
return identifier.remember(environ, identity)
def forget(self, request):
@@ -350,6 +350,14 @@ def test_remember(self):
self.assertEqual(result[0], request.environ)
self.assertEqual(result[1], {'repoze.who.userid':'fred'})
+ def test_remember_kwargs(self):
+ authtkt = DummyWhoPlugin()
+ request = DummyRequest(
+ {'repoze.who.plugins':{'auth_tkt':authtkt}})
+ policy = self._makeOne()
+ result = policy.remember(request, 'fred', max_age=23)
+ self.assertEqual(result[1], {'repoze.who.userid':'fred', 'max_age': 23})
+
def test_forget_no_plugins(self):
request = DummyRequest({})
policy = self._makeOne()

0 comments on commit 3063246

Please sign in to comment.