Description
Expected Behavior
Option to override the default LogoutHandler
(setter) in OidcLogoutEndpointFilter
by OidcLogoutEndpointConfigurer
.
Current Behavior
In the current version the LogoutHandler
is hardcoded in the OidcLogoutEndpointFilter
constructior.
It would be great to have it consistent with LogoutFilter
, Saml2LogoutRequestFilter
, LogoutWebFilter
.
Also please consider usingCompositeLogoutHandler
as in LogoutFilter
and Saml2LogoutRequestFilter
.
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) in OidcLogoutEndpointFilter
and copy quite a lot code from performLogout
private function.
At the same time the implementation of performLogout
function looks a little controversial in case of adding option for logoutHandler
override:
// Check for active user session
if (oidcLogoutAuthentication.isPrincipalAuthenticated() &&
StringUtils.hasText(oidcLogoutAuthentication.getSessionId())) {
// Perform logout
this.logoutHandler.logout(request, response,
(Authentication) oidcLogoutAuthentication.getPrincipal());
}
logoutHandler.logout
is called by condition which could cause problems in case of some custom logoutHandler
or CompositeLogoutHandler
.
Also I have a question about this part of performLogout
function:
if (oidcLogoutAuthentication.isAuthenticated() &&
StringUtils.hasText(oidcLogoutAuthentication.getPostLogoutRedirectUri())) {
// Perform post-logout redirect
UriComponentsBuilder uriBuilder = UriComponentsBuilder
.fromUriString(oidcLogoutAuthentication.getPostLogoutRedirectUri());
String redirectUri;
if (StringUtils.hasText(oidcLogoutAuthentication.getState())) {
uriBuilder.queryParam(
OAuth2ParameterNames.STATE,
UriUtils.encode(oidcLogoutAuthentication.getState(), StandardCharsets.UTF_8));
}
redirectUri = uriBuilder.build(true).toUriString(); // build(true) -> Components are explicitly encoded
this.redirectStrategy.sendRedirect(request, response, redirectUri);
} else {
// Perform default redirect
this.logoutSuccessHandler.onLogoutSuccess(request, response,
(Authentication) oidcLogoutAuthentication.getPrincipal());
}
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
or SimpleUrlLogoutSuccessHandler
in both cases?