Merge pull request #1613 from raehalme/KEYCLOAK-1832
KEYCLOAK-1832 Added check for null authentication on the logout method
This commit is contained in:
commit
85df0b6a67
2 changed files with 11 additions and 2 deletions
|
@ -32,8 +32,11 @@ public class KeycloakLogoutHandler implements LogoutHandler {
|
|||
|
||||
@Override
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
|
||||
if (!KeycloakAuthenticationToken.class.isAssignableFrom(authentication.getClass())) {
|
||||
if (authentication == null) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,12 @@ public class KeycloakLogoutHandlerTest {
|
|||
verifyZeroInteractions(session);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLogoutNullAuthentication() throws Exception {
|
||||
keycloakLogoutHandler.logout(request, response, null);
|
||||
verifyZeroInteractions(session);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleSingleSignOut() throws Exception {
|
||||
keycloakLogoutHandler.handleSingleSignOut(request, response, keycloakAuthenticationToken);
|
||||
|
|
Loading…
Reference in a new issue