问题描述
使用ehcache + terracotta设置shiro会话缓存,将这些配置设置为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插件不是r eading配置,已经使用security.shiro作为前缀
预先感谢
1.配置(覆盖插件定义)适当的shiroSecurityManager bean resources.groovy
:
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)
}
OR
2.在 Bootstrap.groovy
DEF sessionDao =新org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO()
sessionDao.activeSessionsCacheName = 四郎-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
setting up shiro session cache with ehcache+terracotta ,putitng these configs in config.groovy -
security.shiro.sessionDAO = "org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO"
// This name matches a cache name in ehcache.xml:security.shiro.sessionDAO.activeSessionsCacheName = "shiro-activeSessionsCache"security.shiro.securityManager.sessionManager.sessionDAO = "org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO"
// Configure The EhCacheManager:security.shiro.cacheManager = "org.apache.shiro.cache.ehcache.EhCacheManager"security.shiro.cacheManager.cacheManagerConfigFile = "classpath:session_ehcache.xml"
// Configure the above CacheManager on Shiro's SecurityManager// to use it for all of Shiro's caching needs:security.shiro.securityManager.cacheManager = "org.apache.shiro.cache.ehcache.EhCacheManager"
but looks like shiro plugin is not reading configurations, have used "security.shiro" as prefix
Thanks in advance
Figured out this could be done either of one way -
1.Configure (override over plugin definition) proper shiroSecurityManager bean at resources.groovy
:
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")
}
OR
2.Configure shiroSecurityManager at Bootstrap.groovy
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
put -
security.shiro.session.mode="native"
这篇关于Shiro grails插件 - 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!