NutzCN Logo
问答 配置了静态资源,怎么/assets/** = anon没起作用
发布于 2264天前 作者 carolwelcome 2475 次浏览 复制 上一个帖子 下一个帖子
标签:

shiro.ini配置如下:

[main]
#cas
casFilter = org.apache.shiro.cas.CasFilter
casFilter.failureUrl = /WEB-INF/error/404.html
casFilter.successUrl = /platform/login

casRealm = com.jos.index.commons.shiro.realm.JsCasRealm
casRealm.defaultRoles = ROLE_USER
### Change with your own CAS server
casRealm.casServerUrlPrefix = http://localhost:8180/
### and your host name
casRealm.casService = http://localhost:8280/cas

casSubjectFactory = org.apache.shiro.cas.CasSubjectFactory
securityManager.subjectFactory = $casSubjectFactory

### Change with your own CAS server and your host name
user.loginUrl = http://localhost:8180/login?service=http://localhost:8280/cas

# cacheManager
;-------------Redis作为shiro二级缓存时注释掉这里---------
cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
cacheManager.cacheManagerConfigFile = classpath:ehcache.xml
;-------------Redis作为shiro二级缓存时注释掉这里---------

;-------------Redis作为shiro二级缓存时启用这里---------
;jedisAgent = org.nutz.integration.jedis.JedisAgent
;cacheManager_ehcache = org.apache.shiro.cache.ehcache.EhCacheManager
;cacheManager_ehcache.cacheManagerConfigFile=classpath:ehcache.xml
;cacheManager_redis = org.nutz.plugins.cache.impl.redis.RedisCacheManager
;cacheManager_redis.mode=kv
;cacheManager_redis.debug=true
;cacheManager_redis.ttl=3600000
;cacheManager = org.nutz.plugins.cache.impl.lcache.LCacheManager
;cacheManager.jedisAgent = $jedisAgent
;cacheManager.level1 = $cacheManager_ehcache
;cacheManager.level2 = $cacheManager_redis
;-------------Redis作为shiro二级缓存时启用这里---------

# Session
sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
sessionManager.sessionValidationSchedulerEnabled = false

# Session Cache
sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
sessionDAO.cacheManager = $cacheManager
sessionDAO.activeSessionsCacheName = shiro-activeSessionCache
sessionManager.sessionDAO = $sessionDAO
securityManager.sessionManager = $sessionManager

# Cookie
sessionIdCookie = org.apache.shiro.web.servlet.SimpleCookie
sessionIdCookie.name = sid
#sessionIdCookie.domain=wizzer.cn
#sessionIdCookie.path=
sessionIdCookie.maxAge = 946080000
sessionIdCookie.httpOnly = true
sessionManager.sessionIdCookie = $sessionIdCookie
sessionManager.sessionIdCookieEnabled = true
sessionManager.globalSessionTimeout = 3600000


rememberMeCookie = org.apache.shiro.web.servlet.SimpleCookie
rememberMeCookie.name = remember
rememberMeCookie.maxAge = 604800
rememberMeCookie.httpOnly = true
rememberMeManager = com.jos.framework.shiro.remember.LightCookieRememberMeManager
rememberMeManager.cookie = $rememberMeCookie

sha256Matcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
sha256Matcher.storedCredentialsHexEncoded = false
sha256Matcher.hashIterations = 1024
sha256Matcher.hashSalted = true

shiroDbRealm = com.jos.index.commons.shiro.realm.PlatformAuthorizingRealm
shiroDbRealm.credentialsMatcher = $sha256Matcher

securityManager.realms = $casRealm
#$casRealm
authcStrategy = com.jos.framework.shiro.pam.AnySuccessfulStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
securityManager.cacheManager = $cacheManager
securityManager.rememberMeManager = $rememberMeManager

authc = com.jos.index.commons.shiro.filter.PlatformAuthenticationFilter
authc.captchaParam=platformCaptcha
authc.loginUrl = http://localhost:8180/login?service=http://localhost:8280/cas
logout.redirectUrl =/error.html

[urls]
/cas=casFilter
/platform/doLogin = anon
/assets/** = anon
/** = anon
/platform/** = authc

7 回复

大神,请忽略标题,配置了casRm,单点可以登录进去了,但系统不能正常登录了。如何能兼得尼

正常登陆指什么? 账号密码登录?

对,直接就密码错误了

请求有进入 PlatformAuthenticationFilter 吗?

可以进入到PlatformAuthenticationFilter,在subject.login(token)的报错了,异常类型为UnsupportedTokenException:Realm。该Realm继承的是CasRealm,所以不支持CaptchaToken。这种情况应该怎么处理?

那就是你写的Realm不对了, 没有声明好具体的Token类型, 构造方法里面,你参考PlatformAuthorizingRealm

嗯,明白了,谢谢!刚修改了一个配置:securityManager.realms = $casRealm,$shiroDbRealm,直接挂了两个Realm,发现又可以登录了,单点登录也可以使用。amazing!

添加回复
请先登陆
回到顶部