-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Fix #8693 Support SAML 2.0 SP Metadata Endpoints #8795
Conversation
dcfc676
to
901a2f3
Compare
There was a problem hiding this 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.
...rg/springframework/security/saml2/provider/service/servlet/filter/SamlMetadataGenerator.java
Outdated
Show resolved
Hide resolved
...rg/springframework/security/saml2/provider/service/servlet/filter/SamlMetadataGenerator.java
Outdated
Show resolved
Hide resolved
...rg/springframework/security/saml2/provider/service/servlet/filter/SamlMetadataGenerator.java
Outdated
Show resolved
Hide resolved
...rg/springframework/security/saml2/provider/service/servlet/filter/SamlMetadataGenerator.java
Outdated
Show resolved
Hide resolved
...rg/springframework/security/saml2/provider/service/servlet/filter/SamlMetadataGenerator.java
Outdated
Show resolved
Hide resolved
...mework/security/saml2/provider/service/servlet/filter/SamlServiceProviderMetadataFilter.java
Outdated
Show resolved
Hide resolved
...mework/security/saml2/provider/service/servlet/filter/SamlServiceProviderMetadataFilter.java
Outdated
Show resolved
Hide resolved
...mework/security/saml2/provider/service/servlet/filter/SamlServiceProviderMetadataFilter.java
Outdated
Show resolved
Hide resolved
...pringframework/security/saml2/provider/service/servlet/filter/SamlMetadataGeneratorTest.java
Outdated
Show resolved
Hide resolved
...rg/springframework/security/saml2/provider/service/servlet/filter/SamlMetadataGenerator.java
Outdated
Show resolved
Hide resolved
5fd41c6
to
d4e6701
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
...n/java/org/springframework/security/saml2/provider/service/web/OpenSamlMetadataResolver.java
Outdated
Show resolved
Hide resolved
|
||
assertionConsumerService.setLocation( | ||
resolveTemplate(registration.getAssertionConsumerServiceLocation(), registration, request)); | ||
assertionConsumerService.setBinding(registration.getAssertingPartyDetails().getSingleSignOnServiceBinding().getUrn()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
.../main/java/org/springframework/security/config/annotation/web/builders/FilterComparator.java
Outdated
Show resolved
Hide resolved
@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? |
@jkubrynski Are you able to make the requested changes or is there something else that I can help with? |
Hi, sorry but I don't have more time for this PR. Feel free to polish it on your side or simply close it. |
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 Also, to align with #8887 I opted for a simpler contract of just one parameter for |
No description provided.