我有一個非常簡單的安全配置在我的Grails應用3.0.3:Grails的HttpSecurity - 允許POST
@Configuration
@EnableWebSecurity
class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers('/admin/**').hasAnyRole('ADMIN')
.antMatchers('/**').hasAnyRole('USER', 'ADMIN')
//.antMatchers('/').permitAll()
.and()
.formLogin().permitAll()
.and()
.logout().permitAll()
http.headers().frameOptions().disable()
http.csrf().disable()
}
我也有一些DomainClasses其使用@Resource註釋
@Resource(uri="/myresource",formats=['json'])
當我打開關閉/ **路徑認證 - 一切正常。但是,當我爲/ **啓用身份驗證時,包括/ myresource,它不再接受POST請求。那麼返回405方法是不允許的。 如何在Grails 3中使用HttpSecurity允許POST請求?
更新1: GET請求被允許通過驗證的用戶
你好Piotr你解決了這個問題嗎? –