Language correction.
Deal with case where people want to JSON serialize session information. Carry over more parameters in create_attribute_response.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import shelve
|
||||
import six
|
||||
from saml2.ident import code, decode
|
||||
from saml2 import time_util, SAMLError
|
||||
import logging
|
||||
@@ -98,6 +99,8 @@ class Cache(object):
|
||||
if check_not_on_or_after and time_util.after(timestamp):
|
||||
raise ToOld("past %s" % str(timestamp))
|
||||
|
||||
if 'name_id' in info and isinstance(info['name_id'], six.string_types):
|
||||
info['name_id'] = decode(info['name_id'])
|
||||
return info or None
|
||||
|
||||
def set(self, name_id, entity_id, info, not_on_or_after=0):
|
||||
|
@@ -29,8 +29,8 @@ class Unknown(SAMLError):
|
||||
def code(item):
|
||||
"""
|
||||
Turn a NameID class instance into a quoted string of comma separated
|
||||
attribute,value pairs. The attribute name is replaced with a digits.
|
||||
Depends on knowledge on the specific order of the attributes for that
|
||||
attribute,value pairs. The attribute names are replaced with digits.
|
||||
Depends on knowledge on the specific order of the attributes for the
|
||||
class that is used.
|
||||
|
||||
:param item: The class instance
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
from saml2.cache import Cache
|
||||
import six
|
||||
from saml2.cache import Cache
|
||||
from saml2.ident import code
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -20,6 +21,8 @@ class Population(object):
|
||||
this function will overwrite that information"""
|
||||
|
||||
name_id = session_info["name_id"]
|
||||
# make friendly to (JSON) serialization
|
||||
session_info['name_id'] = code(name_id)
|
||||
issuer = session_info["issuer"]
|
||||
del session_info["issuer"]
|
||||
self.cache.set(name_id, issuer, session_info,
|
||||
|
@@ -480,7 +480,7 @@ class Server(Entity):
|
||||
pass
|
||||
|
||||
to_sign = []
|
||||
args = {}
|
||||
|
||||
if identity:
|
||||
_issuer = self._issuer(issuer)
|
||||
ast = Assertion(identity)
|
||||
@@ -505,12 +505,16 @@ class Server(Entity):
|
||||
digest_alg=digest_alg)
|
||||
# Just the assertion or the response and the assertion ?
|
||||
to_sign = [(class_name(assertion), assertion.id)]
|
||||
kwargs['sign_assertion'] = True
|
||||
|
||||
args["assertion"] = assertion
|
||||
kwargs["assertion"] = assertion
|
||||
|
||||
if sp_entity_id:
|
||||
kwargs['sp_entity_id'] = sp_entity_id
|
||||
|
||||
return self._response(in_response_to, destination, status, issuer,
|
||||
sign_response, to_sign, sign_alg=sign_alg,
|
||||
digest_alg=digest_alg, **args)
|
||||
digest_alg=digest_alg, **kwargs)
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
|
@@ -14,19 +14,21 @@ SESSION_INFO_PATTERN = {"ava":{}, "came from":"", "not_on_or_after":0,
|
||||
def _eq(l1, l2):
|
||||
return set(l1) == set(l2)
|
||||
|
||||
|
||||
def nid_eq(l1, l2):
|
||||
return _eq([code(c) for c in l1], [code(c) for c in l2])
|
||||
|
||||
|
||||
nid = [
|
||||
NameID(name_qualifier="foo", format=NAMEID_FORMAT_TRANSIENT, text="1234"),
|
||||
NameID(name_qualifier="foo", format=NAMEID_FORMAT_TRANSIENT, text="9876"),
|
||||
NameID(name_qualifier="foo", format=NAMEID_FORMAT_TRANSIENT, text="1000")]
|
||||
|
||||
|
||||
class TestClass:
|
||||
def setup_class(self):
|
||||
self.cache = Cache()
|
||||
|
||||
|
||||
def test_set(self):
|
||||
not_on_or_after = str_to_time(in_a_while(days=1))
|
||||
session_info = SESSION_INFO_PATTERN.copy()
|
||||
@@ -121,4 +123,3 @@ class TestClass:
|
||||
(ava, inactive) = self.cache.get_identity(nid[2])
|
||||
assert inactive == ["bcde"]
|
||||
assert ava == {}
|
||||
|
||||
|
@@ -10,6 +10,7 @@ IDP_OTHER = "urn:mace:example.com:saml:other:idp"
|
||||
|
||||
nid = NameID(name_qualifier="foo", format=NAMEID_FORMAT_TRANSIENT,
|
||||
text="123456")
|
||||
|
||||
nida = NameID(name_qualifier="foo", format=NAMEID_FORMAT_TRANSIENT,
|
||||
text="abcdef")
|
||||
|
||||
|
@@ -1204,7 +1204,7 @@ class TestServer2():
|
||||
print(aa_policy.__dict__)
|
||||
response = self.server.create_attribute_response(
|
||||
IDENTITY.copy(), "aaa", "http://example.com/sp/",
|
||||
"urn:mace:example.com:sp:1")
|
||||
"http://www.example.com/roland/sp")
|
||||
|
||||
assert response is not None
|
||||
assert response.destination == "http://example.com/sp/"
|
||||
|
Reference in New Issue
Block a user