Skip to content

Commit 7c96fee

Browse files
author
Nick Barrett
committed
Add support for nested NameID children inside AttributeValues.
1 parent bd1ebed commit 7c96fee

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/onelogin/saml2/response.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,22 @@ def get_attributes(self):
347347
attr_name = attribute_node.get('Name')
348348
values = []
349349
for attr in attribute_node.iterchildren('{%s}AttributeValue' % OneLogin_Saml2_Constants.NSMAP['saml']):
350-
values.append(attr.text)
350+
# Remove any whitespace (which may be present where attributes are
351+
# nested inside NameID children).
352+
text = attr.text.strip()
353+
if text:
354+
values.append(text)
355+
356+
# Parse any nested NameID children
357+
for nameid in attr.iterchildren('{%s}NameID' % OneLogin_Saml2_Constants.NSMAP['saml']):
358+
values.append({
359+
'NameID': {
360+
'Format': nameid.get('Format'),
361+
'NameQualifier': nameid.get('NameQualifier'),
362+
'value': nameid.text
363+
}
364+
})
365+
351366
attributes[attr_name] = values
352367
return attributes
353368

0 commit comments

Comments
 (0)