我想使用 Spring Security 进行 JWT 身份验证。但它带有默认身份验证。我正在尝试禁用它,但这样做的旧方法 - 通过 application.properties
禁用它 - 在 2.0 中已弃用。
这是我尝试过的:
@Configuration
public class StackWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().disable();
// http.authorizeRequests().anyRequest().permitAll(); // Also doesn't work.
}
}
我怎样才能简单地禁用基本安全性?
更新
很高兴知道我使用的不是 web mvc 而是 web Flux。
截屏:
原文由 Jan Wytze 发布,翻译遵循 CC BY-SA 4.0 许可协议
根据 Spring 2.0 中的新更新,如果 Spring Security 在类路径中,Spring Boot 将添加 @EnableWebSecurity。因此,向 application.properties 添加条目将不起作用(即,它不再是可定制的方式)。更多信息请访问官网 Spring Boot 2.0 中的安全变化
尽管不确定您的确切要求,但我可以想到一种解决方法,如下所示:-
希望这可以帮助。