spring-securityopenidsaml-2.0

Passing initial query params all the way, in Spring Security OpenID/SAML


I have an OpenID and SAML integration using Spring Security. I'm using the service initiated flow. I would like to pass any query parameter that is present in the initial URL, all the way to the final redirect, after authentication has taken place.

Example flow would be:

  1. User calls localhost:8080/auth-server/openid?param1=value1
  2. The Auth Server asserts that there is no session and redirects to localhost:8080/auth-server/oauth2/authorization/registrationId (this is the default url in OAuth2AuthorizationRequestRedirectFilter.DEFAULT_AUTHORIZATION_REQUEST_BASE_URI)
  3. The Auth Server then redirects to IdP at https://idpurl.com/myAppId?params...
  4. The IdP does authentication and ends up redirecting back to localhost:8080/auth-server/login/oauth2/code/registrationId?params...
  5. The Auth Server finalizes authentication and finally redirects back to the original url localhost:8080/auth-server/openid only this time, there is no param1.

I'm looking for a way to pass param1 all the way to the final redirection. Is this supported in Spring Security? Is there a simple way to do this?


Solution

  • The out of the box solution is to use the SavedRequestAwareAuthenticationSuccessHandler which saves the original request and replays it after authentication is successful for the final redirect.