GWT Keycloak logout redirection

Viewed 172

So I'm struggling with the integration between Keycloak and GWT.

I do have a AsyncCallBackHandler where I do handle the 403 exception and then redirect to logout when session expires.

My problem is the following :

  • I tried the Window.Location.replace("sso/logout") which gives me 502 for some reason when redirecting to login, but works fine with the logout button
  • I tried the Window.Location.replace("http://auth-server/auth/realms/{realm-name}/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri"), it redirects fine to login page, but the problem is when logging in again, I get a weird behaviour like a file gets downloaded and login button gets disabled...

Not sure what I'm doing wrong, any help would be appreciated.

if (ex.getStatusCode() == HttpStatus.SC_FORBIDDEN) {
    Window.Location.replace("sso/logout");
}

Configuration on Spring security side is the following :

http
          .csrf().disable()
          .authorizeRequests()
          .anyRequest().authenticated()
          .and()
          .logout()
          .addLogoutHandler(keycloakLogoutHandler())
          .deleteCookies("JSESSIONID")
          .logoutSuccessUrl("/sso/login");
0 Answers
Related