I want remember url request parameter from first request of my site (SP) and use them after response from IdP.
I'm using spring-saml extension and think about relayState attribute but can't find example how build it with parameters from request.
I need that for redirect user after sso authentication process to target page (module of application) depends on what was in first request.
RelayState is a parameter of the SAML protocol that is used to identify the specific resource the user will access after they are signed in and directed to the relying party's federation server.
The SAML v2 IDP Discovery Service is an implementation of the Identity Provider Discovery Profile as described in the Profiles for the OASIS Security Assertion Markup Language (SAML) V2. 0 specification.
Spring SAML Extension allows seamless inclusion of SAML 2.0 Service Provider capabilities in Spring applications. All products supporting SAML 2.0 in Identity Provider mode (e.g. ADFS 2.0, Shibboleth, OpenAM/OpenSSO, Ping Federate, Okta) can be used to connect with Spring SAML Extension.
Spring SAML sample application behaves like this out of the box. When user hits a page which is protected by Spring Security and requires authentication system:
ExceptionTranslationFilter
and HttpSessionRequestCache
) by storing the information into the HTTP sessionSAMLEntryPoint
class) which redirects user to the IDP, possible after IDP selectionorg.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler
You could of course implement this using relay state as you intended. The correct way to set relay state is by extending SAMLEntryPoint
, overriding method getProfileOptions
and returning your desired relay state in the returned WebSSOProfileOptions
object.
You can then change the AuthenticationSuccessHandler
to org.springframework.security.saml.SAMLRelayStateSuccessHandler
which make redirect to the URL returned from the relay state after successful authentication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With