Shiro grails 插件 - 配置

发布于 2024-12-23 00:45:57 字数 835 浏览 1 评论 0原文

使用 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 插件没有读取配置,已使用“security.shiro”作为前缀

提前致谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话里做英雄 2024-12-30 00:45:57

发现这可以通过一种方式完成 -

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"

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文