Description
I'm currently in the process of migrating my application's authentication from Spring Security SAML Extension to Spring Security SAML. I'm using the service provider metadata to register my application with the Identity Provider (IDP). I've managed to generate the metadata for the service provider, but I'm struggling to figure out how to sign the metadata details.
In the previously generated service provider metadata, you can see the presence of the <ds:Signature></ds:Signature>
section, which was automatically generated by Spring Security SAML Extension. However, in my migration to Spring Security SAML, I haven't found an implementation for signing the metadata in the OpenSamlMetadataResolver
.
Here's a snippet of my code:
SecurityFilterChain configure(HttpSecurity http) throws Exception {
OpenSaml4AuthenticationProvider authenticationProvider = new OpenSaml4AuthenticationProvider();
Saml2MetadataFilter filter = new Saml2MetadataFilter(relyingPartyRegistrationRepository,
new OpenSamlMetadataResolver());
http.addFilterBefore(filter, Saml2WebSsoAuthenticationFilter.class);
http.authorizeHttpRequests(requests -> requests
.requestMatchers("/saml2/service-provider-metadata/**")
.permitAll()
).saml2Login((saml2) -> saml2.loginProcessingUrl(SAML2_ASSERTION_CONSUMER_SERVICE_URL))
.build();
}
The service provider metadata generated by Spring Security SAML Extension includes a <ds:Signature>
section as follows:
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" ID="example.com" entityID="example.com">
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<!-- Signature details here -->
</ds:Signature>
<!-- Other metadata details -->
</md:EntityDescriptor>
My question is, how can I achieve the same feature of generating and adding the <ds:Signature>
section in the service provider metadata using Spring Security SAML?
I've already reviewed the OpenSamlMetadataResolver
implementation, but I couldn't find a built-in way to sign the metadata. Any guidance or code examples on how to achieve this would be greatly appreciated.