【发布时间】:2018-04-26 16:30:32
【问题描述】:
我想使用 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。
【问题讨论】:
-
您是否尝试排除包,如您所见here
-
@Y.Colin 是的,我试过了。我只能通过删除整个依赖项来禁用它..
-
您能再解释一下吗?现在有什么是以前没有的?你的安全配置是什么?你能提供一个请求+响应的例子吗?
-
@BrianClozel 目前它只是一个空应用程序,我只想在没有基本身份验证的情况下使用 Spring Security。您可以通过创建一个 Spring Boot 2.0 Web 应用程序并使用
@EnableWebFlux来复制它。 -
添加
@EnableWebFlux会有效地禁用所有 WebFlux 自动配置。你打算这样做吗?
标签: spring-boot spring-security spring-webflux spring-security-rest