【发布时间】:2015-11-30 16:35:38
【问题描述】:
我的 Grails 3.0.3 应用程序中有一个相当简单的安全配置:
@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()
}
我还有一些使用 @Resource 注释的 DomainClasses
@Resource(uri="/myresource",formats=['json'])
当我关闭 /** 路径的身份验证时 - 一切正常。但是当我为 /** 保留身份验证时,包括 /myresource,它不再接受 POST 请求。然后返回不允许的 405 方法。 如何在 Grails 3 中使用 HttpSecurity 允许 POST 请求?
更新 1: 经过身份验证的用户允许 GET 请求
【问题讨论】:
-
你好 Piotr 问题解决了吗?
标签: grails spring-security grails-3.0