我有一个使用Spring Boot和Spring Security构建的REST API。我从文档中看到Spring Security默认在请求/logout
时默认登录当前用户。但是,我似乎无法得到这个工作。Spring Boot + Spring Security - 无法注销
这是我的安全配置:
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Configuration
class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.httpBasic()
.and()
.csrf().disable();
}
}
然而,当我主动要求/logout
,我收到以下错误:
{
"timestamp": 1485096094269,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/login"
}
你不提供'.logout()' ;见例如https://spring.io/guides/gs/securing-web/。你有什么要求? – jonrsharpe
我其实尝试添加.logout();从我见过的几个不同的例子,但没有效果。您如何建议更改上述示例以启用注销?我正在做的请求是一个“/注销”的GET请求。 – simbro
是的,配置肯定是被称为。我添加了“.logout.permitAll()”我尝试使用POST方法来“/注销”,仍然是相同的消息,并没有注销。别人使用什么作为配置方法? – simbro