gpt4 book ai didi

spring-security - Grails 3 Spring Security application.yml

转载 作者:行者123 更新时间:2023-12-02 19:11:16 24 4
gpt4 key购买 nike

由于某种原因,我的静态规则未应用。

添加“org.grails.plugins:spring-security-core:3.0.0.M1”插件并执行

grails s2-quickstart com.testapp User Role

已成功创建角色用户和 UserRole 域。还创建了一个包含一些设置的 application.groovy 文件。

但我正在使用 application.yml 文件来配置我的应用程序。因此,我将属性移至 application.yml 并删除 .groovy 文件。

由于某种原因,静态规则未应用。可能存在语法错误。

---
grails:
plugin:
springsecurity:
userLookup:
userDomainClassName: 'User'
authorityJoinClassName: 'UserRole'
authority:
className: 'Role'
apf:
postOnly: false
password:
algorithm: 'bcrypt'
controllerAnnotations:
staticRules:
/: permitAll
/error: permitAll
/index: permitAll
/index.gsp: permitAll
/shutdown: permitAll
/assets/**: permitAll
/**/js/**: permitAll
/**/css/**: permitAll
/**/images/**: permitAll
/**/favicon.ico: permitAll
mime:
disable:
accept:
header:
userAgents:
...

我尝试过多种变体,例如

'/': 'permitAll'
/: 'permitAll'

但是每次我打开 localhost:8080/时都会提示我登录!

最佳答案

YML 中新的 Spring 安全配置如下所示:

---
grails:
plugin:
springsecurity:
userLookup.userDomainClassName: 'org...User'
userLookup.authorityJoinClassName: 'org...UserRole'
authority.className: 'org...Role'
controllerAnnotations.staticRules:
- pattern: '/'
access: ['permitAll']
- pattern: '/index'
access: ['permitAll']
- pattern: '/index.gsp'
access: ['permitAll']
- pattern: '/error'
access: ['permitAll']
- pattern: '/user/denied'
access: ['permitAll']
- pattern: '/assets/**'
access: ['permitAll']
- pattern: '/**/js/**'
access: ['permitAll']
- pattern: '/**/css/**'
access: ['permitAll']
- pattern: '/**/images/**'
access: ['permitAll']
- pattern: '/**/favicon.ico'
access: ['permitAll']

出于测试目的(以确保此配置有效)允许所有静态规则之上的所有规则,但请务必稍后将其删除:

- pattern: '/**'
access: ['permitAll']

关于spring-security - Grails 3 Spring Security application.yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33431709/

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