Cannot log out a non-Keycloak authentication

I have spring boot application with embedded UI angular application. Application is using keycloak spring boot adapter.

I am getting exception below from my application, if I logout after access token expired.

2021-Dec-16 14:18:17.992 WARN [https-jsse-nio-8080-exec-5] o.k.a.s.a.KeycloakLogoutHandler - Cannot log out a non-Keycloak authentication: org.springframework.security.authentication.AnonymousAuthenticationToken@cf204d47: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffed504: RemoteIpAddress: 127.0.0.1; SessionId: F1B069D9C731DF372D3B5E74364F0417; Granted Authorities: ROLE_ANONYMOUS

My settings

  • Access Token Lifespan - 1 Minutes
  • SSO Session Idle - 5 Minutes

If I logout before access token lifespan it works fine.

On logout from UI I clears the refresh token and access token from ui app and call the logout which calls the request.logout() and forward to the logout page. on calling logout I am getting exception above.

If I click on login link , It directly opens the application.