summaryrefslogtreecommitdiff
path: root/src/saml2/cache.py
diff options
context:
space:
mode:
authorJozef Knaperek <jknaperek@gmail.com>2016-03-29 18:09:05 +0200
committerJozef Knaperek <jknaperek@gmail.com>2016-03-29 18:09:05 +0200
commitfbb0b5a1e76ff2e638dafcbd8cf6e730d1d68e0a (patch)
treea98ae4ae3495cfc8236e2803adffea520dd122ae /src/saml2/cache.py
parent5388f01e7cf8b5d4b3007b6948e3dae819beec25 (diff)
downloadpysaml2-fbb0b5a1e76ff2e638dafcbd8cf6e730d1d68e0a.tar.gz
Fix Name-ID caching type inconsistency
If we already promoted (in #0515de9f) the saml2.cache.Cache to be a bit smart when it comes to understanding the data it stores - that is decoding name_id in the get() method, let's be consistent and do the reverse operation directly in the set() method. This also fixes the issue with djangosaml2 that PR #321 tried to solve (but ugly way).
Diffstat (limited to 'src/saml2/cache.py')
-rw-r--r--src/saml2/cache.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/saml2/cache.py b/src/saml2/cache.py
index 5b72e9d1..2e2eaa9a 100644
--- a/src/saml2/cache.py
+++ b/src/saml2/cache.py
@@ -113,6 +113,11 @@ class Cache(object):
:param info: The session info, the assertion is part of this
:param not_on_or_after: A time after which the assertion is not valid.
"""
+ info = dict(info)
+ if 'name_id' in info and not isinstance(info['name_id'], six.string_types):
+ # make friendly to (JSON) serialization
+ info['name_id'] = code(name_id)
+
cni = code(name_id)
if cni not in self._db:
self._db[cni] = {}