Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow duplicate named attributes in SAML2 assertions #261

Merged
merged 8 commits into from
Jun 17, 2021

Conversation

doticatto
Copy link

In the SAML spec, the "friendlyName" is defined as a completely optional for attribute naming, and should not be relied upon for retrieving attributes. It exists simply to provide a more human-readable method to decipher attributes. From the spec (https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf):

FriendlyName [Optional]
A string that provides a more human-readable form of the attribute's name, which may be useful in cases in which the actual Name is complex or opaque, such as an OID or a UUID. This attribute's value MUST NOT be used as a basis for formally identifying SAML attributes.

This MR adds the possibility of multiple attributes with the same FriendlyName, and creates a list with all of the attributes with the same FriendlyName appended to it.

@pitbulk
Copy link
Contributor

pitbulk commented Jun 4, 2021

In the php-saml toolkit, we added a new setting to allow/disallow duplicated Names/Friendlynames
In order to be aligned, we should implement it here in a similar way.

Are you able to extend your PR to allow duplicate names or friendlynames, when the new setting is enabled?

@doticatto
Copy link
Author

doticatto commented Jun 5, 2021 via email

@pitbulk
Copy link
Contributor

pitbulk commented Jun 5, 2021

At php-saml it was a new setting parameter at the advanced section: allowRepeatAttributeName

Here is the commit that introduced the feature on php-saml: SAML-Toolkits/php-saml@370a5d9

@doticatto
Copy link
Author

I have updated the MR to pass the style checks, added tests for both the positive and negative cases, and condensed the attribute retrieval logic into one method.

I added a setting under security that mirrors the name in the php-saml repo, and a settings file called settings11.json to ensure the attribute loading works as intended.

@doticatto doticatto changed the title Allow duplicate friendlyname attributes in SAML2 assertions Allow duplicate named attributes in SAML2 assertions Jun 7, 2021
@doticatto
Copy link
Author

@pitbulk Any changes requested?

if attr_text:
values.append(attr_text)

# Parse any nested NameID children
Copy link
Contributor

@pitbulk pitbulk Jun 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed the support of the nested NameID children, we need to keep supporting it.

@doticatto
Copy link
Author

doticatto commented Jun 16, 2021 via email

@doticatto
Copy link
Author

@pitbulk there is an existing test for getting nested NameID attributes, and the code is still included in the _get_attributes() method.

The testGetNestedNameIDAttributes test on line 760 of response_test.py tests this scenario and still passes as expected. Unless I am misunderstanding the issue I do not believe it breaks support for this case

@doticatto
Copy link
Author

I added a test for nested NameID attributes when retrieving FriendlyName attributes, all tests pass as expected. Please let me know if I have missed something

@pitbulk pitbulk merged commit ef2efa7 into SAML-Toolkits:master Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants