gpt4 book ai didi

grails - Shiro Grails插件-配置

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

使用ehcache + terracotta设置shiro session 缓存,并将这些配置放入config.groovy-

security.shiro.sessionDAO =“org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO”

//此名称与ehcache.xml中的缓存名称匹配:
security.shiro.sessionDAO.activeSessionsCacheName =“shiro-activeSessionsCache”
security.shiro.securityManager.sessionManager.sessionDAO =“org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO”

//配置EhCacheManager:
security.shiro.cacheManager =“org.apache.shiro.cache.ehcache.EhCacheManager”
security.shiro.cacheManager.cacheManagerConfigFile =“classpath:session_ehcache.xml”

//在Shiro的SecurityManager上配置上述CacheManager
//将其用于Shiro的所有缓存需求:
security.shiro.securityManager.cacheManager =“org.apache.shiro.cache.ehcache.EhCacheManager”

但看起来shiro插件未读取配置,已使用“security.shiro”作为前缀

提前致谢

最佳答案

弄清楚这可以通过以下任一方法完成-

1.在resources.groovy上配置(覆盖插件定义)适当的shiroSecurityManager bean:

myShiroSessionDAO(org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO) {
activeSessionsCacheName="shiro-activeSessionsCache"
}
myShiroSessionManager(org.apache.shiro.web.session.mgt.DefaultWebSessionManager) {
sessionDAO = ref("myShiroSessionDAO")
}
myShiroCacheManager(org.apache.shiro.cache.ehcache.EhCacheManager) {
cacheManagerConfigFile = "classpath:session_ehcache.xml"
//cacheManager = CacheManager.create()
}
shiroSecurityManager(org.apache.shiro.web.mgt.DefaultWebSecurityManager) {
cacheManager = ref("myShiroCacheManager")
sessionManager = ref("myShiroSessionManager")
}

要么

2.在 Bootstrap.groovy上配置shiroSecurityManager
def sessionDao = new org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO()
sessionDao.activeSessionsCacheName="shiro-activeSessionCache"
shiroSecurityManager.sessionManager.sessionDAO = sessionDao
def cacheManager = new org.apache.shiro.cache.ehcache.EhCacheManager()
cacheManager.cacheManagerConfigFile = "classpath:session_ehcache.xml"
shiroSecurityManager.cacheManager = cacheManager

@ Config.groovy放-
security.shiro.session.mode="native"

关于grails - Shiro Grails插件-配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8633910/

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