I am facing a issue with spring boot logout.
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/", true)
.permitAll()
.and()
.httpBasic();
// Logout
http.logout().deleteCookies("remove")
.invalidateHttpSession(false)
.logoutUrl("/logout").permitAll()
.logoutSuccessUrl("/login").permitAll();
}
After login, if I try to access 'http://localhost:8080/logout', it fails with:
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Jan 04 17:40:21 BRT 2021 There was an unexpected error (type=Not Found, status=404). No message available
--Edit Attempting now to access logout via POST, causes error 403 and sometimes 401.
Javascript:
function logout() {
$.post("/logout", {});
}
HTML:
<li class="nav-item">
<a href="javascript:logout()" class="nav-link">Sair</a>
</li>