Spring security 允许get请求但不允许post请求(Spring安全性)

Spring security 允许get请求但不允许post请求(Spring安全性),spring-security,Spring Security,我尝试配置Spring安全性。我有以下配置: @Override protected void configure(HttpSecurity http) throws Exception { http .csrf().disable() .authorizeRequests() .antMatchers("/auth**").permitAll()

我尝试配置Spring安全性。我有以下配置:

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .csrf().disable()
                .authorizeRequests()
                    .antMatchers("/auth**").permitAll()
                .and()
                .authorizeRequests()
                    .antMatchers("/**").authenticated()
                    .anyRequest().permitAll()
                .and()
                    .httpBasic()
                .and()
                    .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and()
                    .userDetailsService(userDetailsService());
    }
我可以向以“/auth”开头的链接发送get请求,但在没有身份验证的情况下无法发送post请求。如果我删除以下代码,一切正常:

.authorizeRequests()
.antMatchers("/**").authenticated()
.anyRequest().permitAll()

但我需要在任何页面上进行身份验证,除了“/auth**”

一个很晚的答案,但像大多数人一样,我讨厌回答没有答案的问题。我想您是在问如何防止对/auth**进行身份验证

您应该重写其他配置方法:

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.POST, "/auth/**");
}
这将不会对该URL执行任何身份验证。 换句话说,它是一个公共URL,人们可以通过它发布提醒密码请求