gpt4 book ai didi

grails - 访问Grails Shiro插件中的特定 Controller

转载 作者:行者123 更新时间:2023-12-02 13:56:40 24 4
gpt4 key购买 nike

我有一个grails应用程序,其中使用shiro插件来增加安全性。如果没有登录任何用户,我将不提供对任何URL的访问权限。一切顺利。现在,我想找到是否可以通过某种方式在不登录的情况下访问某些URL?某些链接应该无需登录即可工作。

最佳答案

这很容易。如果您具有标准的shiro设置,则将在项目ShiroSecurityFilters.groovy -folder中找到一个conf,它看起来像这样:

class SecurityFilters {
def filters = {
all(uri: "/**") {
before = {
// Ignore direct views (e.g. the default main index page).
if (!controllerName) return true
// Access control by convention.
accessControl()
}
}
}
}

只需将其替换为以下内容:
class SecurityFilters {
def filters = {
all(uri: "/**") {
before = {
// Ignore direct views (e.g. the default main index page).
if (!controllerName) return true
// Access control by convention.
if ((controllerName+':'+actionName) in ['book:view', 'book:list']) {
return true
} else {
accessControl()
}
}
}
}
}

这将使每个人都可以访问 list的两个 Action viewbookController

希望有帮助...

关于grails - 访问Grails Shiro插件中的特定 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20612498/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com