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

Add NameIdFormat support to RelyingPartyRegistration #9115

Closed
Gayathri92 opened this issue Oct 8, 2020 · 13 comments
Closed

Add NameIdFormat support to RelyingPartyRegistration #9115

Gayathri92 opened this issue Oct 8, 2020 · 13 comments
Assignees
Labels
in: saml2 An issue in SAML2 modules type: enhancement A general enhancement
Milestone

Comments

@Gayathri92
Copy link

Gayathri92 commented Oct 8, 2020

RelyingPartyRegistration contains SAML 2.0 Metadata for both the relying party and its associated asserting party.

It would be nice to include NameIDFormat support in both RelyingPartyRegistration and RelyingPartyRegistration.AssertingPartyDetails. The application could then communicate a set of preferred formats to the asserting party (with #9297, for example) as well as lookup the asserting party's preferred formats.

@Gayathri92 Gayathri92 added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Oct 8, 2020
@jzheaux
Copy link
Contributor

jzheaux commented Oct 14, 2020

Thanks for reaching out, @Gayathri92. Would you please add some more detail about your use case?

@jzheaux jzheaux added in: saml2 An issue in SAML2 modules and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 14, 2020
@jzheaux jzheaux added the status: waiting-for-feedback We need additional information before we can continue label Nov 12, 2020
@jzheaux jzheaux self-assigned this Nov 12, 2020
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Nov 19, 2020
@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Nov 26, 2020
@amergey
Copy link
Contributor

amergey commented Dec 1, 2020

@jzheaux I saw your mention, I will try to submit a PR for this

@amergey
Copy link
Contributor

amergey commented Dec 2, 2020

We have some customers where specifying NameIdFormat is mandated by their IDP

NameIdFormat is a part of NameIDPolicy which support others attributes
According to SAML Core specification:

The <NameIDPolicy> element tailors the name identifier in the subjects of assertions resulting from an
<AuthnRequest>. Its NameIDPolicyType complex type defines the following attributes:

Format [Optional]
Specifies the URI reference corresponding to a name identifier format defined in this or another
specification (see Section 8.3 for examples). The additional value of
urn:oasis:names:tc:SAML:2.0:nameid-format:encrypted is defined specifically for use
within this attribute to indicate a request that the resulting identifier be encrypted.

SPNameQualifier [Optional]
Optionally specifies that the assertion subject's identifier be returned (or created) in the namespace of
a service provider other than the requester, or in the namespace of an affiliation group of service
providers. See for example the definition of urn:oasis:names:tc:SAML:2.0:nameidformat:persistent in Section 8.3.7.

AllowCreate [Optional]
A Boolean value used to indicate whether the identity provider is allowed, in the course of fulfilling the
request, to create a new identifier to represent the principal. Defaults to "false". When "false", the
requester constrains the identity provider to only issue an assertion to it if an acceptable identifier for
the principal has already been established. Note that this does not prevent the identity provider from
creating such identifiers outside the context of this specific request (for example, in advance for a
large number of principals).

With some IDP, or the way it is configured, some Format value mandates the SPNameQualifier attributes to be set as well. (We saw that most of the time with PingFeredarate but with some others as well).

So in the PR instead of adding support for Format only, I also added support to configure the whole NameIDPolicy, in order to ease interop with some IDP use case

@jzheaux jzheaux changed the title Require NameIdFormat field in RelyingPartyRegistration. Add NameIdFormat support to RelyingPartyRegistration Dec 18, 2020
@jzheaux
Copy link
Contributor

jzheaux commented Dec 18, 2020

Good points, @amergey. I think I created some confusion by not first updating the description in this ticket. It's updated now.

The reason I'd like to leave changes to OpenSamlAuthenticationRequestFactory out of this PR is I'd like to see what happens with #9277 first since that may obviate the need to change the factory.

Would you be able to update the PR to match the issue's description?

@amergey
Copy link
Contributor

amergey commented Dec 21, 2020

@jzheaux Do you mean updating this PR by keeping only nameid format ? (so remove other part of nameid policy but keeping related work on metadata ?) . Also correct me if I am wrong but it seems to me NameID format is defined at SP level, there is no IDP metadatas related to NameID format.

@jzheaux
Copy link
Contributor

jzheaux commented Jan 5, 2021

Sorry for the delay, @amergey, I was on holiday.

Do you mean updating this PR by keeping only nameid format

Yes, since that's the only one that appears in metadata.

NameID format is defined at SP level, there is no IDP metadatas related to NameID format.

I was drawing my thoughts from line 658 of the spec in the SSODescriptorType section:

[Zero or More]
Zero or more elements of type anyURI that enumerate the name identifier formats supported by
this system entity acting in this role. See Section 8.3 of [SAMLCore] for some possible values for
this element.

which applies to both IDPSSODescriptor and SPSSODescriptor.

That said, I think it would be fine to only add it to the relying party for now. We can always add it to AssertingPartyDetails later if necessary.

@amergey
Copy link
Contributor

amergey commented Jan 7, 2021

NameID format is defined at SP level, there is no IDP metadatas related to NameID format.

I was drawing my thoughts from line 658 of the spec in the SSODescriptorType section:

[Zero or More]
Zero or more elements of type anyURI that enumerate the name identifier formats supported by
this system entity acting in this role. See Section 8.3 of [SAMLCore] for some possible values for
this element.

which applies to both IDPSSODescriptor and SPSSODescriptor.

That said, I think it would be fine to only add it to the relying party for now. We can always add it to AssertingPartyDetails later if necessary.

Sorry I was not clear enough, when I said "NameID format is defined at SP level, there is no IDP metadatas related to NameID format." I meant in OpenSAML implementation so it would be hard to support it on IDP anyway

@PHameete
Copy link

PHameete commented Nov 5, 2021

Hello all! Thank you for the discussion so far. I have an interest in this issue as well.

Currently if a Relying Party wishes to request the NameID in a specific format the suggested way in the docs is to modify the AuthnRequest as specified here https://docs.spring.io/spring-security/site/docs/current/reference/html5/#servlet-saml2login-opensaml-customization

It would be nice if the NameIDFormat field as present on the SPSSODescriptor field of the EntityDescriptor could be defined via the RelyingPartyRegistration. I think that would be more elegant than modifying a value 'last minute' in the AuthnRequest marshaller, and it would be present on the Relying Party metadata to allow for dynamic configuration as well.

I imagine this would be used as follows:

        RelyingPartyRegistrations
            .fromMetadataLocation(identityProvider.getMetadataUrl())
            .registrationId(identityProvider.getRegistrationId())
            .assertingPartyDetails(builder -> builder.setNameIdFormat(NameIDType.EMAIL))
            .build();

@fr2lancer
Copy link

Also it would be good to access it by

Saml2AuthenticationRequestContext.getRelyingPartyRegistration().getAssertingPartyDetails().**

@Bas83
Copy link

Bas83 commented Nov 22, 2021

Unfortunately the link @PHameete shared seems to have been removed from the Spring docs, but an older version is up at https://docs.spring.io/spring-security/site/docs/5.5.2/reference/html5/#servlet-saml2login-opensaml-customization

amergey added a commit to amergey/spring-security that referenced this issue Nov 22, 2021
amergey added a commit to amergey/spring-security that referenced this issue Nov 22, 2021
@jzheaux jzheaux closed this as completed in a17dfb8 Dec 1, 2021
@jzheaux jzheaux added this to the 6.0.0-M1 milestone Dec 1, 2021
jzheaux pushed a commit that referenced this issue Dec 1, 2021
@PHameete
Copy link

PHameete commented Dec 1, 2021

Thank you @jzheaux!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: saml2 An issue in SAML2 modules type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants