diff options
| author | Wichert Akkerman <wichert@wiggy.net> | 2010-12-28 21:07:19 +0100 |
|---|---|---|
| committer | Wichert Akkerman <wichert@wiggy.net> | 2010-12-28 21:07:19 +0100 |
| commit | 17c4de891ad41c03c6e5e007f8100f02033b4555 (patch) | |
| tree | 2468ff6ca9a82d0791e88ddee7e982ffd6902de4 | |
| parent | 43520cf4eb67cd24eaacbe8f3f42928abc469b2f (diff) | |
| download | pyramid-17c4de891ad41c03c6e5e007f8100f02033b4555.tar.gz pyramid-17c4de891ad41c03c6e5e007f8100f02033b4555.tar.bz2 pyramid-17c4de891ad41c03c6e5e007f8100f02033b4555.zip | |
When using the auth_tkt authentication plugin accept a ``tokens`` parameter in emember.
| -rw-r--r-- | CHANGES.txt | 3 | ||||
| -rw-r--r-- | pyramid/authentication.py | 3 | ||||
| -rw-r--r-- | pyramid/tests/test_authentication.py | 17 |
3 files changed, 21 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index ebf3bf4e2..2264f50e2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,9 @@ Bug Fixes Features -------- +- When using the auth_tkt authentication plugin accept a ``tokens`` parameter + in :py:func:`pyramid.security.remember`. + - If a resource implements a ``__resource_url__`` method, it will be called as the result of invoking the ``pyramid.url.resource_url`` function to generate a URL, overriding the default logic. See the new "Generating The diff --git a/pyramid/authentication.py b/pyramid/authentication.py index 86d725bcf..b80429c72 100644 --- a/pyramid/authentication.py +++ b/pyramid/authentication.py @@ -415,7 +415,7 @@ class AuthTktCookieHelper(object): environ = request.environ return self._get_cookies(environ, '', max_age=EXPIRE) - def remember(self, request, userid, max_age=None): + def remember(self, request, userid, max_age=None, tokens=()): max_age = max_age or self.max_age environ = request.environ @@ -436,6 +436,7 @@ class AuthTktCookieHelper(object): self.secret, userid, remote_addr, + tokens=tokens, user_data=user_data, cookie_name=self.cookie_name, secure=self.secure) diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py index d9d0c2c97..5f30d0d22 100644 --- a/pyramid/tests/test_authentication.py +++ b/pyramid/tests/test_authentication.py @@ -568,7 +568,22 @@ class TestAuthTktCookieHelper(unittest.TestCase): self.assertEqual(values[0]['max-age'], '500') self.failUnless(values[0]['expires']) - + + def test_remember_tokens(self): + plugin = self._makeOne('secret') + request = self._makeRequest() + result = plugin.remember(request, 'other', tokens=('foo', 'bar')) + self.assertEqual(len(result), 3) + + self.assertEqual(result[0][0], 'Set-Cookie') + self.failUnless("'tokens': ('foo', 'bar')" in result[0][1]) + + self.assertEqual(result[1][0], 'Set-Cookie') + self.failUnless("'tokens': ('foo', 'bar')" in result[1][1]) + + self.assertEqual(result[2][0], 'Set-Cookie') + self.failUnless("'tokens': ('foo', 'bar')" in result[2][1]) + def test_forget(self): plugin = self._makeOne('secret') request = self._makeRequest() |
