如何使用Grails Spring Security Plugin(Requestmap)

时间:2014-08-21 14:03:32

标签: grails-2.3

Grails spring security fails to present the login page due to a redirect loop

我必须在哪里写这个?

new Requestmap(url: '/*', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save();

1 个答案:

答案 0 :(得分:0)

从Spring.io的博客文章Dynamic Request Maps部分获取的信息,标题为“使用Grails简化Spring安全性”。

  

要启用此机制,请将以下内容添加到Config.groovy:

import grails.plugins.springsecurity.SecurityConfigType
...
grails.plugins.springsecurity.securityConfigType = SecurityConfigType.Requestmap
     

您需要做的就是创建Requestmap域的实例   class,例如BootStrap.groovy

new Requestmap(url: '/timeline', configAttribute: 'ROLE_USER').save()
new Requestmap(url: '/person/*', configAttribute: 'IS_AUTHENTICATED_REMEMBERED').save()
new Requestmap(url: '/post/followAjax', configAttribute: 'ROLE_USER').save()
new Requestmap(url: '/post/addPostAjax', configAttribute: 'ROLE_USER,IS_AUTHENTICATED_FULLY').save()
new Requestmap(url: '/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()