I'm using spring security with REST, and I'm using the URL (/logout
) as an endpoint for my logout method. But after calling this method, it redirect me to (/login?logout
), I know this is the spring logOutSuccessUrl
. And I want to get rid of the redirection. This is my code:
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/login").permitAll()
.anyRequest().fullyAuthenticated()
.and().requiresChannel().anyRequest().requiresSecure()
.and().httpBasic().disable().logout()
.disable()
// .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))
.csrf().disable();
}
I tried to use HttpStatusReturningLogoutSuccessHandler
but it didn't work, and even setting logoutSuccessUrl()
doesn't change anything.
Do you know how can I disable this redirection?
Following code works for me (notice that it doesn't have logout().disable()
)
http.logout().permitAll();
http.logout().logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With