【问题标题】:how used Grails Spring Security Plugin (Requestmap)如何使用 Grails Spring Security Plugin (Requestmap)
【发布时间】:2014-10-15 05:01:49
【问题描述】:

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

我必须在哪里写这个?

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

【问题讨论】:

    标签: grails-2.3


    【解决方案1】:

    信息来自 Spring.io 博客文章“Simplified Spring Security with Grails”的Dynamic Request Maps 部分。

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

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

    然后您所要做的就是创建Requestmap 域的实例 类,例如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() 
    

    【讨论】:

    • 谢谢:)。仅在 BootStrap 中?
    • 否,但在您需要安全路由的任何 .groovy 文件中。BootStrap.groovy 只是一个示例。
    猜你喜欢
    • 2015-12-31
    • 2015-03-20
    • 1970-01-01
    • 2014-10-06
    • 2015-04-22
    • 2012-06-26
    • 2012-11-19
    • 2011-09-20
    • 1970-01-01
    相关资源
    最近更新 更多