Spring boot Spring安全性:无法启用permitAll()来发布API
我正在尝试将spring安全性实现到PostAPI-Spring boot Spring安全性:无法启用permitAll()来发布API,spring-boot,spring-security,Spring Boot,Spring Security,我正在尝试将spring安全性实现到PostAPI- http?.authorizeRequests() ?.antMatchers(HttpMethod.POST, "/user/details")?.permitAll() ?.antMatchers("/user/**")?.hasRole("admin") ?.and()
http?.authorizeRequests()
?.antMatchers(HttpMethod.POST, "/user/details")?.permitAll()
?.antMatchers("/user/**")?.hasRole("admin")
?.and()
?.formLogin()
但是,permitAll()
似乎不起作用。但是,如果我将HttpMethod.POST
替换为HttpMethod.GET
,则其下的GET请求将按照预期遵循antMatcher
规则
POST请求有不同的方式吗?- Spring security默认情况下启用
。因此,通过您的配置,csrf已启用csrf
不适用于csrf
请求,但适用于GET
、PUT
、DELETE
和POST
PATCH
- 因此,出于测试目的,您也可以将其添加到配置中
和您的http.csrf().disable()
将起作用POST
csrf
启用,并将csrf
令牌作为修改请求的一部分发送