Skip to content

Commit 59a01c9

Browse files
teknott-dodc00kiemon5ter
authored andcommitted
Multiple AttributeStatement tags per Assertion
This was necessary to implement a real-world SSO integration, which required handlinge multiple AttributeStatement elements within a single assertion in a SAML response. Orginally this change was implemented in a private fork by Thomas Knott for pysaml 2.2.0, and has been ported by Sheila Allen for use in pysaml 4.6.0 to hopefully merge upstream. There was a similar PR for the same need by pcrownov: https://github.com/IdentityPython/pysaml2/pull/205/files
1 parent 5a84453 commit 59a01c9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/saml2/response.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def read_attribute_statement(self, attr_statem):
649649
self.allow_unknown_attributes)
650650

651651
def get_identity(self):
652-
""" The assertion can contain zero or one attributeStatements
652+
""" The assertion can contain zero or more attributeStatements
653653
654654
"""
655655
ava = {}
@@ -662,9 +662,11 @@ def get_identity(self):
662662
ava.update(self.read_attribute_statement(
663663
tmp_assertion.attribute_statement[0]))
664664
if _assertion.attribute_statement:
665-
assert len(_assertion.attribute_statement) == 1
666-
_attr_statem = _assertion.attribute_statement[0]
667-
ava.update(self.read_attribute_statement(_attr_statem))
665+
logger.debug("Assertion contains %s attribute statement(s)",
666+
(len(self.assertion.attribute_statement)))
667+
for _attr_statem in _assertion.attribute_statement:
668+
logger.debug("Attribute Statement: %s" % (_attr_statem,))
669+
ava.update(self.read_attribute_statement(_attr_statem))
668670
if not ava:
669671
logger.debug("Assertion contains no attribute statements")
670672
return ava

0 commit comments

Comments
 (0)