Search in sources :

Example 1 with KeycloakLogoutHandler

use of org.keycloak.adapters.springsecurity.authentication.KeycloakLogoutHandler in project vboard by voyages-sncf-technologies.

the class WebSecurityConfig method configureKeycloakSecurity.

protected void configureKeycloakSecurity(HttpSecurity http) throws Exception {
    // Not @Autowiring those beans as they may not be available because of the @Conditional
    final AdapterDeploymentContext adc = applicationContext.getBean(AdapterDeploymentContext.class);
    final KeycloakPreAuthActionsFilter keycloakPreAuthActionsFilter = applicationContext.getBean(KeycloakPreAuthActionsFilter.class);
    http.addFilterBefore(keycloakPreAuthActionsFilter, LogoutFilter.class).addFilterBefore(keycloakAuthenticationProcessingFilter(), BasicAuthenticationFilter.class).exceptionHandling().authenticationEntryPoint(new KeycloakAuthenticationEntryPoint(adc));
    http.logout().addLogoutHandler(new KeycloakLogoutHandler(adc)).logoutUrl("/sso/logout").permitAll().logoutSuccessUrl("/");
}
Also used : AdapterDeploymentContext(org.keycloak.adapters.AdapterDeploymentContext) KeycloakLogoutHandler(org.keycloak.adapters.springsecurity.authentication.KeycloakLogoutHandler) LogoutFilter(org.springframework.security.web.authentication.logout.LogoutFilter) KeycloakPreAuthActionsFilter(org.keycloak.adapters.springsecurity.filter.KeycloakPreAuthActionsFilter) KeycloakAuthenticationEntryPoint(org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationEntryPoint)

Aggregations

AdapterDeploymentContext (org.keycloak.adapters.AdapterDeploymentContext)1 KeycloakAuthenticationEntryPoint (org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationEntryPoint)1 KeycloakLogoutHandler (org.keycloak.adapters.springsecurity.authentication.KeycloakLogoutHandler)1 KeycloakPreAuthActionsFilter (org.keycloak.adapters.springsecurity.filter.KeycloakPreAuthActionsFilter)1 LogoutFilter (org.springframework.security.web.authentication.logout.LogoutFilter)1