【发布时间】:2021-09-02 16:03:55
【问题描述】:
我有这个 WebSecurityConfigurerAdapter 配置:
@EnableWebSecurity
public class HttpSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.cors()
.and()
.authorizeRequests()
.mvcMatchers("/auth/**").permitAll()
.anyRequest().authenticated()
.and()
.oauth2ResourceServer().jwt()
;
}
}
当我向auth 发出请求时,我得到一个 401,直到我通过了一些授权 - 这不适合这个 endopint。
我认为这与.anyRequest().authenticated() 有关。我之前读过这不应该影响permitAll()s - 我是否配置错误?
【问题讨论】:
-
有没有返回401的路径示例
-
您是否使用 @EnableWebSecurity 注释了您的配置类?
-
@AkifHadziabdic "POST /auth/test"
-
@Nemanja 是的
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
标签: java spring spring-boot security spring-security