zoukankan      html  css  js  c++  java
  • shiro 实现 用户 a 操作b 的权限 ,用户 b 能够及时获知。b不需要退出登陆 。 关闭鉴权缓存,或者不配置缓存

    <bean id="myRealm" class="com.diancai.util.MyRealm">
            <property name="userService" ref="userService"/>
            <property name="credentialsMatcher" ref="credentialsMatcher"/>
            <!-- <property name="cachingEnabled" value="true"/>
            <property name="authenticationCachingEnabled" value="true"/>
            <property name="authenticationCacheName" value="authenticationCache"/>
            <property name="authorizationCacheName" value="authorizationCache"/> -->
            <property name="authorizationCachingEnabled" value="false"/>
            <!-- 如果设置成false,关闭鉴权缓存。那么每次验证权限的时候由于默认读取缓存中的权限信息,
                如果读取不到信息就会再次请求realm中的doGetAuthrizationInfo方法获得权限.
                需求:以此实现 权限的动态读取,而不是一次读取一直有效。保证管理员操作用户权限,用户能及时更新
                (也可以不配置缓存机制,自然实现上述需求)-->
        </bean>




    <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
            <property name="realm" ref="myRealm"></property>
            <property name="rememberMeManager" ref="rememberMeManager"></property>
            <property name="cacheManager" ref="shiroEhcacheManager" />
        </bean>
        <!-- 用户授权信息Cache, 采用EhCache -->
        <bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
            <property name="cacheManagerConfigFile" value="classpath:security/ehcache-shiro.xml"/>
        </bean>
    
    
    
    
    
    <ehcache updateCheck="false" name="shiroCache">
    
        <defaultCache
                maxElementsInMemory="10000"
                eternal="false"
                timeToIdleSeconds="120"
                timeToLiveSeconds="120"
                overflowToDisk="false"
                diskPersistent="false"
                diskExpiryThreadIntervalSeconds="120"
                />
    </ehcache>
    
    
    


  • 相关阅读:
    MYSQL5.6学习——mysqldump备份与恢复
    【转】分布式与集群的区别
    (四)伪分布式下jdk1.6+Hadoop1.2.1+HBase0.94+Eclipse下运行wordCount例子
    (三)配置Hadoop1.2.1+eclipse(Juno版)开发环境,并运行WordCount程序
    git pull总是要输入账号和密码
    Undefined index: validate(thinkphp)
    mysql table status
    如何学习web开发环境搭建和脚手架
    serversql tinkphp
    apache 配置
  • 原文地址:https://www.cnblogs.com/zhangchenglzhao/p/4435282.html
Copyright © 2011-2022 走看看