-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow customizing LogoutHandler in OidcLogoutEndpointFilter #1244
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
The internal
Can you provide details on the problem you forsee? |
Hi @jgrandja and thank you for such a quick reply! I hope my explanation wasn't too confusing, but to summarise I can say that the main problem is having to copy code from a private |
@finke-ba Thanks for the explanation. I'll review the customization capabilities of the other Filter's you mentioned and will look at aligning the same in |
@jgrandja Great to hear that. |
@finke-ba If you can submit a PR that would be great 👍 |
@jgrandja Perfect, I'll submit a PR and mention you to review it, hopefully this week! |
We found the need to customize the I ended up making the Instead of passing the class OidcLogoutAuthenticationPrincipalLogoutSuccessHandler implements LogoutSuccessHandler {
private final LogoutSuccessHandler delegate;
// ...
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
if (authentication instance of OidcLogoutAuthenticationToken oidc) {
this.delegate.onLogoutSuccess(request, response, (Authentication) oidc.getPrincipal());
}
}
} |
@finke-ba You can now customize the OidcLogoutAuthenticationSuccessHandler oidcLogoutAuthenticationSuccessHandler =
new OidcLogoutAuthenticationSuccessHandler();
oidcLogoutAuthenticationSuccessHandler.setLogoutHandler(customLogoutHandler);
authorizationServerConfigurer
.oidc(oidc ->
oidc
.logoutEndpoint(logoutEndpoint ->
logoutEndpoint.logoutResponseHandler(oidcLogoutAuthenticationSuccessHandler))); |
We don't need to expose If you need to configure public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
private final LogoutHandler logoutHandler = new SecurityContextLogoutHandler();
private LogoutSuccessHandler logoutSuccessHandler; // TODO Init Saml2RelyingPartyInitiatedLogoutSuccessHandler
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
this.logoutHandler.logout(request, response, authentication);
this.logoutSuccessHandler.onLogoutSuccess(request, response, authentication);
}
} Makes sense? |
Expected Behavior
Option to override the default
LogoutHandler
(setter) inOidcLogoutEndpointFilter
byOidcLogoutEndpointConfigurer
.Current Behavior
In the current version the
LogoutHandler
is hardcoded in theOidcLogoutEndpointFilter
constructior.It would be great to have it consistent with
LogoutFilter
,Saml2LogoutRequestFilter
,LogoutWebFilter
.Also please consider using
CompositeLogoutHandler
as inLogoutFilter
andSaml2LogoutRequestFilter
.Context
I'm trying to add a couple custom actions for OIDC logout, but at the moment I have to override whole default
AuthenticationSuccessHandler
(performLogout function) inOidcLogoutEndpointFilter
and copy quite a lot code fromperformLogout
private function.At the same time the implementation of
performLogout
function looks a little controversial in case of adding option forlogoutHandler
override:logoutHandler.logout
is called by condition which could cause problems in case of some customlogoutHandler
orCompositeLogoutHandler
.Also I have a question about this part of
performLogout
function:In this code, I am confused by the fact that the
logoutSuccessHandler
will not always be called, but only by a condition.It seems to me that the point of this logic is to redirect the user by
postLogoutRedirectUri
or default uri(which is "/").So, could you please explain why it's not possible to use
redirectStrategy
orSimpleUrlLogoutSuccessHandler
in both cases?The text was updated successfully, but these errors were encountered: