首页 > 解决方案 > Spring Boot 2 http.httpBasic().disable(); 不工作

问题描述

我最近从 Spring Boot 1.x 升级到 Spring Boot 2.0.3,我试图禁用基本身份验证但没有成功。

@Configuration
@EnableWebSecurity(debug=true)
@EnableGlobalMethodSecurity(securedEnabled = true)
public class CustomSecurity extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        super.configure(http);
        http.httpBasic().disable();
        // the rest of my config
    }
}

我缺少什么隐藏的宝石来简单地关闭基本身份验证?为什么现在在 Spring 中关闭事物需要如此困难?

我正在阅读此内容: https ://github.com/spring-projects/spring-boot/issues/10306 ,我必须同意它应该更容易,并且应该就如何关闭它提供更清晰的解释。

编辑

此链接https://spring.io/blog/2017/09/15/security-changes-in-spring-boot-2-0-m4 讨论了如何删除该属性,但没有说明如何继续使用配置,因为它存在于使用它的当前应用程序中。

标签: spring-bootspring-securitybasic-authentication

解决方案


推荐阅读