【发布时间】:2013-05-20 03:50:18
【问题描述】:
我有一个 Grails (2.0.4) 应用程序,它使用 Spring Security 插件(版本 1.2.7.3)和安全注释方法(默认方法,更多 here)。
现在,我在 UrlMapping.groovy 中有这些带有资源键或控制器/操作对的 URL,如下所示:
"/$controller/$action?/$id?" {
constraints {
// apply constraints here
}
}
// other rules, all working properly
"/api/item/$id?"(resource: 'itemRest')
'/api/item/batch-delete'(controller: 'itemRest', action: 'batchDelete')
RESTful 映射与 ItemRestController 完美配合:每个方法(显示、更新、保存、删除)都正确映射到正确的 HTTP 方法。额外的方法 (batchDelete) 也有效。
我保护了 API url,这样做:
grails.plugins.springsecurity.controllerAnnotations.staticRules = [
// ...
'/something/**': ['IS_AUTHENTICATED_FULLY']
'/api/**': ['IS_AUTHENTICATED_FULLY']
]
现在,如果我打电话,我会被重定向到登录页面:
http://host/context/something/bla_bla
但如果我调用(需要时使用适当的有效负载)则不会:
http://host/context/api/item/batchDelete
http://host/context/api/item/1
http://host/context/api/item
我的怀疑是在使用资源键映射其余控制器时静态规则无法正常工作。
另请注意,UrlMapping.groovy 文件中不存在“某事”网址。
有什么想法吗?
【问题讨论】:
标签: rest grails spring-security url-mapping