Added check for null authentication on the logout method.
This commit is contained in:
parent
1c38bb7158
commit
e0eac89e5a
2 changed files with 11 additions and 2 deletions
|
@ -32,8 +32,11 @@ public class KeycloakLogoutHandler implements LogoutHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||||
|
if (authentication == null) {
|
||||||
if (!KeycloakAuthenticationToken.class.isAssignableFrom(authentication.getClass())) {
|
log.warn("Cannot log out without authentication");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!KeycloakAuthenticationToken.class.isAssignableFrom(authentication.getClass())) {
|
||||||
log.warn("Cannot log out a non-Keycloak authentication: {}", authentication);
|
log.warn("Cannot log out a non-Keycloak authentication: {}", authentication);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,12 @@ public class KeycloakLogoutHandlerTest {
|
||||||
verifyZeroInteractions(session);
|
verifyZeroInteractions(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLogoutNullAuthentication() throws Exception {
|
||||||
|
keycloakLogoutHandler.logout(request, response, null);
|
||||||
|
verifyZeroInteractions(session);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandleSingleSignOut() throws Exception {
|
public void testHandleSingleSignOut() throws Exception {
|
||||||
keycloakLogoutHandler.handleSingleSignOut(request, response, keycloakAuthenticationToken);
|
keycloakLogoutHandler.handleSingleSignOut(request, response, keycloakAuthenticationToken);
|
||||||
|
|
Loading…
Reference in a new issue