青野 发表于 2017-12-21 06:34:13

Shrio+Redis实现tomcat集群session共享

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"
  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  
xmlns:util="http://www.springframework.org/schema/util"
  
xsi:schemaLocation="http://www.springframework.org/schema/beans
  
http://www.springframework.org/schema/beans/spring-beans.xsd
  
http://www.springframework.org/schema/util
  
http://www.springframework.org/schema/util/spring-util.xsd">
  

  
<description>Shiro Configuration</description>
  

  
<!--shiro-redis redisCacheManager-->
  
<bean>
  
<property name="keyPrefix" value="shiro_redis_session:"/>
  
<property name="redisManager" ref="redisClient"/>
  
</bean>
  

  
<!--custom myself realm-->
  
<bean>
  
<property name="cacheManager" ref="redisCacheManager"/>
  
</bean>
  

  
<!--redisSessionDAO-->
  
<bean></bean>
  

  


  
<!--simpleCookie,不定义在集群环境下会出现There is no session with>  
<bean>
  
<constructor-arg name="name" value="custom.session"/>
  
<property name="path" value="/"/>
  
</bean>
  

  
<!--sessionManager-->
  
<bean>
  
<property name="sessionDAO" ref="redisSessionDAO"/>
  
<property name="sessionIdCookie" ref="simpleCookie"/>
  
</bean>
  

  
<!--Shiro`s main business-tier object for web-enable applications-->
  
<bean>
  
<property name="realm" ref="customRealm"/>
  
<property name="cacheManager" ref="redisCacheManager"/>
  
<property name="sessionManager" ref="sessionManager"/>
  
</bean>
  

  
<!--shiro filter-->
  
<bean>
  
<property name="securityManager" ref="securityManager"/>
  
<property name="loginUrl" value="/login.html"/>
  
<property name="successUrl" value="/index.html"/>
  
<property name="unauthorizedUrl" value="/unauthorized.html"/>
  
<property name="filters">
  
<util:map>
  
<entry key="auth">
  
<bean/>
  
</entry>
  
</util:map>
  
</property>
  
<property name="filterChainDefinitions">
  
<value>
  
/login.json = anon
  
/logout.json = anon
  
/js/** = anon
  
/ = authc
  
/** = auth
  
</value>
  
</property>
  
</bean>
  
</beans>
页: [1]
查看完整版本: Shrio+Redis实现tomcat集群session共享