Java 安全配置未保护所有终结点
我想用jwt令牌保护每个端点,因此我创建了以下配置:Java 安全配置未保护所有终结点,java,spring-boot,spring-security,Java,Spring Boot,Spring Security,我想用jwt令牌保护每个端点,因此我创建了以下配置: @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests()
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest()
.authenticated()
.and()
.oauth2ResourceServer()
.jwt();
}
}
这适用于post请求,但我的所有get请求仍然有效。当我在没有承载令牌的情况下执行get请求时,它仍然有效。
我做错了什么?您是否在
SecurityConfig
中有@覆盖配置(WebSecurity web)
。如果是,请验证您没有在同一数据库中添加端点。