Spring Boot 2 升级。permit All 使用 .anonymous().and() .. 但为什么呢?

use*_*209 5 oauth spring-security oauth-2.0 spring-boot

我已经从 Spring Boot 1.3.2 T Spring Boot 2.0.2 迁移了 Oauth2 代码。

下面允许“/auth”端点的代码在 springBoot 2 中不起作用

public void configure(HttpSecurity httpSecurity) throws Exception {
        httpSecurity                
                .exceptionHandling()
                .authenticationEntryPoint(customAuthenticationEntryPoint)
                .and()
                .antMatchers("/auth/**").permitAll()
                .anyRequest()
                .authenticated();

    }
Run Code Online (Sandbox Code Playgroud)

/auth 端点返回 401 响应。

经过研究,我已经添加了

.anonymous().and()

它现在按预期工作。/auth 返回没有令牌的结果。

我无法弄清楚原因,spring boot 2 发生了什么变化。?