-
Notifications
You must be signed in to change notification settings - Fork 6k
Customizing the metadata endpoint does not work #9133
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
Comments
Thanks, @dawi, for the report. I think we should update the documentation. The filter by default expects the filter.setRequestMatcher(new AntPathRequestMatcher("/saml2/metadata/{registrationId}", "GET")); Would you be able to provide a PR updating the documentation? |
Requiring the I understand that Update: I have found a really hacky workaround: One could use Update 2: If a custom |
Another thing I don't understand is that currently the URL should contain a filter.setRequestMatcher(new AntPathRequestMatcher("/saml2/metadata/{registrationId}", "GET")); but this pattern seems not to be used to parse the So if someone want's to set a metadata url like All in all, it would be nice if it could be simpler to configure the metadata url. If spring security could offer such a solution, then maybe spring boot would adopt this too, and the metadata URL could also be configured via |
Do you have a proposal for how to make things simpler?
The repository's API is intended to be reduceable to a single-tenant application, it's not a "happy accident". In your situation, I see two possibilities:
There may be ways to simplify this as well for the other scenarios you outlined, and I'm open to your thoughts. Most things are private in |
For the single-tenant scenario, you can replace the default resolver with a lambda, like so: @Bean
Filter metadata(RelyingPartyRegistrationRepository relyingPartyRegistrationRepository) {
Saml2MetadataFilter metadata = new Saml2MetadataFilter(
(request) -> relyingPartyRegistrationRepository.findByRegistrationId("single"),
new OpenSamlMetadataResolver());
metadata.setRequestMatcher(new AntMathRequestMatcher("/saml2/metadata", "GET"));
return metadata;
} This is about the same level of simplicity as the default @Bean
Filter metadata(RelyingPartyRegistrationRepository relyingPartyRegistrationRepository) {
Saml2MetadataFilter metadata = new Saml2MetadataFilter(
new DefaultRelyingPartyRegistrationResolver(relyingPartyRegistrationRepository),
new OpenSamlMetadataResolver());
return metadata;
} For multi-tenant scenarios, it's important to remember that a path matcher may be used to both identify endpoints as well as resolve registration ids, but it's not required. The way to figure out the registration id may be completely different (for example, by subdomain). Any application can use a custom As reports of more use cases come in, I think improvements to I think the best step forward right now is to clarify the documentation. |
I think you are right. In retrospect, it is quite easy to configure, and yet very flexible. |
Describe the bug
The documentation states that the metadata endpoint can be changed by like this:
But it does not work as expected because the registration id resolver returns
metadata
as registration id due to the used ant matcher.spring-security/saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/web/DefaultRelyingPartyRegistrationResolver.java
Line 61 in 6714112
spring-security/saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/web/DefaultRelyingPartyRegistrationResolver.java
Line 116 in 6714112
The text was updated successfully, but these errors were encountered: