Skip to content

Fix #8693 Support SAML 2.0 SP Metadata Endpoints #8795

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

Conversation

jkubrynski
Copy link
Contributor

No description provided.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 4, 2020
@jkubrynski jkubrynski force-pushed the features/saml-metadata-generator branch from dcfc676 to 901a2f3 Compare July 4, 2020 08:39
Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

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

Thanks, @jkubrynski! I've left some feedback inline.

@jzheaux jzheaux self-assigned this Jul 8, 2020
@jzheaux jzheaux added in: saml2 An issue in SAML2 modules type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 8, 2020
@jkubrynski jkubrynski force-pushed the features/saml-metadata-generator branch from 5fd41c6 to d4e6701 Compare July 14, 2020 20:03
Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, @jkubrynski. I've left some additional feedback inline.

private AuthenticationManager authenticationManager;

private Saml2WebSsoAuthenticationFilter saml2WebSsoAuthenticationFilter;

private Saml2MetadataFilter saml2MetadataFilter;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems a little odd to provide this as part of saml2Login(). For now, let's leave it out of the DSL as an application can add the filter directly with addFilter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Entity ID patterns used as defaults across spring-security-saml map to the URL, which for me suggest this URL should be available without any external configuration. Why do you think it's odd?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you think it's odd?

Because saml2Login() indicates an authentication mechanism, so it should only contain filters related to that.

For example, saml2Login() isn't the place to configure SAML logout.

without any external configuration

Can you elaborate on this point? What I'm suggesting is that an application do:

http
    .saml2Login(saml2 -> {})
    .addFilter(new Saml2MetadataFilter(new OpenSamlMetadataResolver()));

which already seems simple.

@@ -299,12 +300,14 @@ public static Builder withRelyingPartyRegistration(RelyingPartyRegistration regi
private final String entityId;
private final boolean wantAuthnRequestsSigned;
private final String singleSignOnServiceLocation;
private final String nameIdFormat;
Copy link
Contributor

Choose a reason for hiding this comment

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

AssertingPartyDetails represents metadata for the asserting party, i.e. IDPSSODescriptor.

Since you are generating relying party metadata, I would have thought this would be defined in the relying party section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NameID is a part of the IDPSSODescriptor

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it's in both. You can see it listed for SPSSODescriptor in this metadata overview document on page 8, section 2.14.

There may be value in adding this in both places, but since we're generating an SPSSODescriptor for this ticket, let's please focus on that use case.


assertionConsumerService.setLocation(
resolveTemplate(registration.getAssertionConsumerServiceLocation(), registration, request));
assertionConsumerService.setBinding(registration.getAssertingPartyDetails().getSingleSignOnServiceBinding().getUrn());
Copy link
Contributor

Choose a reason for hiding this comment

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

The AssertingPartyDetails#singleSignOnServiceBinding conceptually maps to the <SingleSignOnService binding='...'/> attribute.

Instead, I think this should probably be set to POST until RelyingPartyRegistration#assertionConsumerServiceBinding is added in #8776

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You cannot simply hardcode POST here, as REDIRECT is pretty common in Saml. I don't get the problem with such usage as above

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you thinking #8776 should be done first? I think it's okay to wait for that.

I don't get the problem with such usage as above

The problem with the above usage is that SingleSignOnService#binding is IDP metadata, but you are generating SP metadata. Since you are wanting to show AssertionConsumerService#binding, you'll want to retrieve that from a semantically equivalent source.

REDIRECT is pretty common in Saml

AFAIK, SAML doesn't allow the usage of REDIRECT for SAML assertions. In the spec line 421 says:

In step 5, the identity provider issues a message to be delivered by the user agent to the service provider. Either the HTTP POST, or HTTP Artifact binding can be used to transfer the message to the service provider through the user agent. The message may indicate an error, or will include (at least) an authentication assertion. The HTTP Redirect binding MUST NOT be used, as the response will typically exceed the URL length permitted by most user agents.

That doesn't mean that ppl don't do it, but it does mean simplifying that specific use case is a lower priority.

@@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.security.saml2.provider.service.servlet.filter;
package org.springframework.security.saml2.provider.service.web;
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate you being proactive here, but moving things will take a bit more work so that things stay backward compatible. While new filters like Saml2MetadataFilter should go into web, let's please wait on moving existing filters until #8819

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cannot move new filters without moving the rest or changing the visibility of *Utils classes to public. Are you OK with the second one?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, the Utils classes should not be made public. I'd recommend inlining that support, as was done with DefaultSaml2AuthenticationRequestContextResolver. Once everything gets moved, then the code can be changed to call the Utils classes again.

@jzheaux
Copy link
Contributor

jzheaux commented Jul 16, 2020

@jkubrynski It looks like something funny happened in a recent push -- I'm seeing other commits in your PR. Can you rebase so that only your commits show?

@jzheaux
Copy link
Contributor

jzheaux commented Jul 23, 2020

@jkubrynski Are you able to make the requested changes or is there something else that I can help with?

@jkubrynski
Copy link
Contributor Author

Hi, sorry but I don't have more time for this PR. Feel free to polish it on your side or simply close it.

@jzheaux jzheaux added this to the 5.4.0-RC1 milestone Aug 5, 2020
@jzheaux jzheaux added the status: duplicate A duplicate of another issue label Aug 5, 2020
@jzheaux
Copy link
Contributor

jzheaux commented Aug 5, 2020

Thanks for your contributions here, @jkubrynski, I was able to complete the PR.

I took your commits and squashed them in 8a35524 and then applied a polish in b999faa.

Some of your contributions were left out since more discussion is probably needed to introduce them. First, metadata configuration was left out of the saml2Login DSL. Second, support for SPSSODescriptor#nameIDFormat was left out of OpenSamlMetadataResolver. These can be revisited in additional tickets if you need that support.

Also, to align with #8887 I opted for a simpler contract of just one parameter for Saml2MetadataResolver.

@jzheaux jzheaux closed this Aug 5, 2020
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 status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants