I have a spring-boot application using spring-security. The security configuration is split into multiple instances of WebSecurityConfigurerAdapter
.
I have one where I configure logout in general:
@Override
protected void configure(HttpSecurity http) throws Exception {
// configure logout
http
.logout()
.logoutUrl("/logout")
.invalidateHttpSession(true)
.addLogoutHandler((request, response, authentication) -> {
System.out.println("logged out 1!");
})
.permitAll();
// ... more security configuration, e.g. login, CSRF, rememberme
}
And there is another WebSecurityConfigurerAdapter
, where I want to do almost nothing, except adding another LogoutHandler:
@Override
protected void configure(HttpSecurity http) throws Exception {
// configure logout
http
.logout()
.logoutUrl("/logout")
.addLogoutHandler((request, response, authentication) -> {
System.out.println("logged out 2!");
});
}
Both configure()
methods are called. However, if I do log out, only the first LogoutHandler
is called. Changing the @Order
of both configurations does not change the result.
What is missing in my configuration?