Spring security 当只应用了authenticated()检查时,这个Spring安全antMatcher配置应用于多个URL是否冗余?

Spring security 当只应用了authenticated()检查时,这个Spring安全antMatcher配置应用于多个URL是否冗余?,spring-security,Spring Security,我只是被Spring Security盯上了,当时我正在检查公司代码库的安全配置。我们的配置如下所示: http .anonymous() .disable() .authorizeRequests() .antMatchers(PUT, "/sap/v6/**").authenticated()

我只是被Spring Security盯上了,当时我正在检查公司代码库的安全配置。我们的配置如下所示:

                http
                .anonymous()
                .disable()
                .authorizeRequests()
                .antMatchers(PUT, "/sap/v6/**").authenticated()
                .antMatchers("/sap/v6/**").authenticated()
                .anyRequest().authenticated()
                .and()
                .csrf()
                .disable();
这部分配置让我好奇:

                .antMatchers(PUT, "/sap/v6/**").authenticated()
                .antMatchers("/sap/v6/**").authenticated()
                .anyRequest().authenticated()
如果我的理解是正确的,所有这些配置说明:

1) 。如果url是/sap/v6/**并且是PUT方法,则必须对请求进行身份验证

2) 。否则,如果url为/sap/v6/**则必须对其进行身份验证

3) 。对于任何其他请求,仅经过身份验证即可,无需授权

这不是多余的吗?如果我把配置缩短到下面,它会起到同样的作用吗

                http
                .anonymous()
                .disable()
                .authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .csrf()
                .disable();

谢谢

正确,仅使用
anyRequest()。authenticated()
将获得相同的结果。