我有一个使用Spring Boot和Spring Security构建的REST API。我从文档中了解到,Spring Security默认在用户请求
这是我的安全配置:
然而,当我向
/logout
时注销当前用户。然而,我似乎无法让它起作用。这是我的安全配置:
@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();
,但没有效果。你建议如何更改上面的示例以启用注销?我正在向“/ logout”发出GET请求。 - simbro