【问题标题】:Allowing a method to be public using interceptMap in Grails Spring Security plugin允许在 Grails Spring Security 插件中使用interceptMap 公开方法
【发布时间】:2014-03-14 13:30:27
【问题描述】:

如何使用带有 Grails Spring Security 插件的 interceptMap 向公众开放控制器的方法?

我有一个这样的网址:

http://localhost:8080/testapp/user/showIdentity?token=2&userID=b18cac92f0636da8fcd464d5b595b9aba86b5f11

所以在我的 interceptMap 中我有:

grails.plugin.springsecurity.interceptUrlMap = [
    '/':                  ['permitAll'],
    '/index':             ['permitAll'],
    '/index.gsp':         ['permitAll'],
    '/**/js/**':          ['permitAll'],
    '/**/css/**':         ['permitAll'],
    '/**/images/**':      ['permitAll'],
    '/**/favicon.ico':    ['permitAll'],
    '/login/**':          ['permitAll'],
    '/logout/**':         ['permitAll'],        
    '/**':         ['ROLE_ADMIN']   
    ]

什么是允许控制器的“showIdentity”方法作为 permitAll 和其他控制器方法作为 ROLE_ADMIN 这是控制器的默认值?

我知道使用 Spring Security ACL 插件我们可以做更多的事情,但我想知道我是否可以使用 Spring Security 插件来做这件事。

【问题讨论】:

    标签: grails spring-security authorization


    【解决方案1】:

    添加这两个应该可以:

    '/user/showIdentity':   ['permitAll'],
    '/user/showIdentity.*': ['permitAll'],
    

    /user/showIdentity.xml 之类的请求需要第二个。其他/user/** 请求将由/** 规则匹配。

    【讨论】:

    猜你喜欢
    • 2016-05-24
    • 2017-05-26
    • 2014-12-13
    • 2011-08-15
    • 2016-03-23
    • 2012-09-29
    • 2014-01-02
    • 2015-08-08
    • 2015-10-19
    相关资源
    最近更新 更多