ch4mpy / spring-addons

Ease spring OAuth2 resource-servers configuration and testing
Apache License 2.0
521 stars 84 forks source link

Per request post-login and post-logout URIs #169

Closed ch4mpy closed 7 months ago

ch4mpy commented 7 months ago

Is your feature request related to a problem? Please describe. Currently, default success and failure handlers support only one post-login and one post-logout URI defined in application properties.

It would be quite convenient that the frontend can provide with a header or query param the URI to which the user should be redirected after login / logout.

Describe the solution you'd like When the frontend provides with a post-login URI when initiating an authorization-code flow, this URI could be saved in session and later used in authentication success / failure handlers (after the client exchanged the authorization-code for tokens or the authentication process failed for whatever reason).

Same for RP-Initiated Logout: if the frontend provides with a post logout URI when initiating logout, then it would be nice that this URI is used instead of the one in application properties.

Describe alternatives you've considered Define (Server)OAuth2AuthorizationRequestResolver of my own, but this feature is rather recurrent and this leads to quite some duplicated code.

Additional context This feature enables to keep the current route in the frontend when login can be initiated from several places. It also enables to serve several frontends with a single BFF.

ch4mpy commented 7 months ago

Released with 7.3.0. The headers, request params and session attributes used by the default (Server)OAuth2AuthorizationRequestResolver, authentication success & failure handlers, and logout success handler are exposed by SpringAddonsOidcClientProperties