Skip to content

Commit b388501

Browse files
author
Roland Hedberg
committed
And AuthnQuery response can potentially contain more than one assertion. Even using the saml2int profile ?
Wrong context value for AuthnQueryResponse.
1 parent cdd7351 commit b388501

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/saml2/response.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -762,19 +762,28 @@ def _encrypted_assertion(self, xmlstr):
762762
return self._assertion(assertion)
763763

764764
def parse_assertion(self):
765-
try:
766-
assert len(self.response.assertion) == 1 or \
767-
len(self.response.encrypted_assertion) == 1
768-
except AssertionError:
769-
raise Exception("No assertion part")
765+
if self.context == "AuthnQuery":
766+
# can contain one or more assertions
767+
pass
768+
else: # This is a saml2int limitation
769+
try:
770+
assert len(self.response.assertion) == 1 or \
771+
len(self.response.encrypted_assertion) == 1
772+
except AssertionError:
773+
raise Exception("No assertion part")
770774

771775
if self.response.assertion:
772776
logger.debug("***Unencrypted response***")
773-
return self._assertion(self.response.assertion[0])
777+
for assertion in self.response.assertion:
778+
if not self._assertion(assertion):
779+
return False
780+
return True
774781
else:
775782
logger.debug("***Encrypted response***")
776-
return self._encrypted_assertion(
777-
self.response.encrypted_assertion[0])
783+
for assertion in self.response.encrypted_assertion:
784+
if not self._encrypted_assertion(assertion):
785+
return False
786+
return True
778787

779788
def verify(self):
780789
""" Verify that the assertion is syntactically correct and
@@ -883,7 +892,7 @@ def __init__(self, sec_context, attribute_converters, entity_id,
883892
self.entity_id = entity_id
884893
self.attribute_converters = attribute_converters
885894
self.assertion = None
886-
self.context = "AuthnQueryResponse"
895+
self.context = "AuthnQuery"
887896

888897
def condition_ok(self, lax=False): # Should I care about conditions ?
889898
return True

0 commit comments

Comments
 (0)