博客转载:http://blog.csdn.net/userrefister/article/details/47807075

/**

* Shiro-1.2.2内置的FilterChain

* @see =========================================================================================================

* @see 1)Shiro验证URL时,URL匹配成功便不再继续匹配查找(所以要注意配置文件中的URL顺序,尤其在使用通配符时)

* @see   故filterChainDefinitions的配置顺序为自上而下,以最上面的为准

* @see 2)当运行一个Web应用程序时,Shiro将会创建一些有用的默认Filter实例,并自动地在[main]项中将它们置为可用

* @see   自动地可用的默认的Filter实例是被DefaultFilter枚举类定义的,枚举的名称字段就是可供配置的名称

* @see   anon---------------org.apache.shiro.web.filter.authc.AnonymousFilter

* @see   authc--------------org.apache.shiro.web.filter.authc.FormAuthenticationFilter

* @see   authcBasic---------org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter

* @see   logout-------------org.apache.shiro.web.filter.authc.LogoutFilter

* @see   noSessionCreation--org.apache.shiro.web.filter.session.NoSessionCreationFilter

* @see   perms--------------org.apache.shiro.web.filter.authz.PermissionAuthorizationFilter

* @see   port---------------org.apache.shiro.web.filter.authz.PortFilter

* @see   rest---------------org.apache.shiro.web.filter.authz.HttpMethodPermissionFilter

* @see   roles--------------org.apache.shiro.web.filter.authz.RolesAuthorizationFilter

* @see   ssl----------------org.apache.shiro.web.filter.authz.SslFilter

*@see   user---------------org.apache.shiro.web.filter.authz.UserFilter

* @see =========================================================================================================

* @see 3)通常可将这些过滤器分为两组

* @see   anon,authc,authcBasic,user是第一组认证过滤器

* @see   perms,port,rest,roles,ssl是第二组授权过滤器

* @see   注意user和authc不同:当应用开启了rememberMe时,用户下次访问时可以是一个user,但绝不会是authc,因为authc是需要重新认证的

* @see   user表示用户不一定已通过认证,只要曾被Shiro记住过登录状态的用户就可以正常发起请求,比如rememberMe

* @see   说白了,以前的一个用户登录时开启了rememberMe,然后他关闭浏览器,下次再访问时他就是一个user,而不会authc

* @see ==========================================================================================================

* @see 4)举几个例子

* @see   /admin=authc,roles[admin]      表示用户必需已通过认证,并拥有admin角色才可以正常发起'/admin'请求

* @see   /edit=authc,perms[admin:edit]  表示用户必需已通过认证,并拥有admin:edit权限才可以正常发起'/edit'请求

* @see   /home=user                     表示用户不一定需要已经通过认证,只需要曾经被Shiro记住过登录状态就可以正常发起'/home'请求

* @see ==========================================================================================================

* @see 5)各默认过滤器常用如下(注意URL Pattern里用到的是两颗星,这样才能实现任意层次的全匹配)

* @see   /admins/**=anon             无参,表示可匿名使用,可以理解为匿名用户或游客

* @see   /admins/user/**=authc       无参,表示需认证才能使用

* @see   /admins/user/**=authcBasic  无参,表示httpBasic认证

* @see   /admins/user/**=user        无参,表示必须存在用户,当登入操作时不做检查

* @see   /admins/user/**=ssl         无参,表示安全的URL请求,协议为https

* @see   /admins/user/**=perms[user:add:*]

* @see    参数可写多个,多参时必须加上引号,且参数之间用逗号分割,如/admins/user/**=perms["user:add:*,user:modify:*"]

* @see    当有多个参数时必须每个参数都通过才算通过,相当于isPermitedAll()方法

* @see   /admins/user/**=port[8081]

* @see     当请求的URL端口不是8081时,跳转到schemal://serverName:8081?queryString

* @see     其中schmal是协议http或https等,serverName是你访问的Host,8081是Port端口,queryString是你访问的URL里的?后面的参数

* @see   /admins/user/**=rest[user]

* @see       根据请求的方法,相当于/admins/user/**=perms[user:method],其中method为post,get,delete等

* @see   /admins/user/**=roles[admin]

* @see     参数可写多个,多个时必须加上引号,且参数之间用逗号分割,如/admins/user/**=roles["admin,guest"]

* @see     当有多个参数时必须每个参数都通过才算通过,相当于hasAllRoles()方法

* @see

================================================================================================================

http://liureying.blog.163.com/blog/static/61513520136205574873/
spring中 shiro logout 配置方式
有两种方式实现logout
1. 普通的action中 实现自己的logout方法,取到Subject,然后logout
这种需要在ShiroFilterFactoryBean 中配置 filterChainDefinitions 
对应的action的url为anon
<property name="filterChainDefinitions">
            <value>
                # some example chain definitions:
                /index.htm = anon
                /logout = anon
                /unauthed = anon
                /console/** = anon
                /css/** = anon
                /js/** = anon
                /lib/** = anon
                /admin/** = authc, roles[admin]
                /docs/** = authc, perms[document:read]
                /** = authc
                # more URL-to-FilterChain definitions here
            </value>

2. 使用shiro提供的logout filter
需要定义 相应的bean
<bean id="logout" class="org.apache.shiro.web.filter.authc.LogoutFilter">
        <property name="redirectUrl" value="/loginform" />
    </bean>

然后将相应的url filter配置为logout如下
<property name="filterChainDefinitions">
            <value>
                # some example chain definitions:
                /index.htm = anon
                /logout = logout
                /unauthed = anon
                /console/** = anon
                /css/** = anon
                /js/** = anon
                /lib/** = anon
                /admin/** = authc, roles[admin]
                /docs/** = authc, perms[document:read]
                /** = authc
                # more URL-to-FilterChain definitions here
            </value>

 
注:anon,authcBasic,auchc,user是认证过滤器,perms,roles,ssl,rest,port是授权过滤器

Shiro 权限管理filterChainDefinitions过滤器配置的更多相关文章

  1. xml配置文件中对于Shiro 权限管理filterChainDefinitions过滤器配置

    博客转载:http://blog.csdn.net/userrefister/article/details/47807075 /** * Shiro-1.2.2内置的FilterChain * @s ...

  2. shrio 权限管理filterChainDefinitions过滤器配置(转)

    shrio 权限管理filterChainDefinitions过滤器配置 /** * Shiro-1.2.2内置的FilterChain * @see ======================= ...

  3. shrio 权限管理filterChainDefinitions过滤器配置

    /** * Shiro-1.2.2内置的FilterChain * @see ============================================================= ...

  4. shrio 权限管理filterChainDefinitions过滤器配置(转)

    /** * Shiro-1.2.2内置的FilterChain * @see ============================================================= ...

  5. SpringMVC+Shiro权限管理(转载)

    源码 http://pan.baidu.com/s/1pJzG4t1 SpringMVC+Shiro权限管理 博文目录 权限的简单描述 实例表结构及内容及POJO Shiro-pom.xml Shir ...

  6. Spring Boot Shiro 权限管理 【转】

    http://blog.csdn.net/catoop/article/details/50520958 主要用于备忘 本来是打算接着写关于数据库方面,集成MyBatis的,刚好赶上朋友问到Shiro ...

  7. (39.4) Spring Boot Shiro权限管理【从零开始学Spring Boot】

    在读此文章之前您还可能需要先了解: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...

  8. (39.2). Spring Boot Shiro权限管理【从零开始学Spring Boot】

    (本节提供源代码,在最下面可以下载) (4). 集成Shiro 进行用户授权 在看此小节前,您可能需要先看: http://412887952-qq-com.iteye.com/blog/229973 ...

  9. (39.1) Spring Boot Shiro权限管理【从零开始学Spring Boot】

    (本节提供源代码,在最下面可以下载)距上一个章节过了二个星期了,最近时间也是比较紧,一直没有时间可以写博客,今天难得有点时间,就说说Spring Boot如何集成Shiro吧.这个章节会比较复杂,牵涉 ...

随机推荐

  1. 九度OJ 1334:占座位 (模拟)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:864 解决:202 题目描述: sun所在学校的教室座位每天都是可以预占的. 一个人可以去占多个座位,而且一定是要连续的座位,如果占不到他所 ...

  2. python(pytest)+allure+jenkins 实现接口自动化的思路

    效果图镇楼: 上述各模块作用: python(pytest): 1:用于读测试用例(本次用例写在csv文件中) 2:环境配置相关 3:提取1中的测试数据,组成请求体 4:发送请求 5:获取结果 6:断 ...

  3. Django 之Form组件

    Django之From组件 扩展:Django 之 ModelForm组件 Form组件功能 Django的Form主要具有一下几大功能 生成HTML标签 验证用户数据(显示错误信息) HTML Fo ...

  4. eclispse + tomcat 启动是不加载项目的解决办法

    有一个java spring的项目一直好好的,突然一天不能启动了.eclipse的console没有报任何错误,相关的server配置也没有问题,经过一翻折腾顺便还把eclipse从indigo升级到 ...

  5. Java并发之ArrayBlockingQueue

    ArrayBlockingQueue是一个由数组支持的有界阻塞队列.此队列按 FIFO(先进先出)原则对元素进行排序.队列的头部是在队列中存在时间最长的元素.队列的尾部是在队列中存在时间最短的元素.新 ...

  6. STM32L0 HAL库 IO读写功能

    开发环境使用 MDK5.16a + CUBEMX生成代码 开发板使用:NUCLEO-L053R8 核心芯片:STM32L053R8 今天主要学习了下最基础的IO的读写,IO使用 PA5   LED输出 ...

  7. 分布式文件存储——GlusterFS

    一.概论 1.简介 GlusterFS (Gluster File System) 是一个开源的分布式文件系统,主要由 Z RESEARCH 公司负责开发. GlusterFS 是 Scale-Out ...

  8. Shell传参的多种方式

    Shell 传参的多种方式 使用$1 $2 这种类似占位符的方式 # 命令行调用 start.sh 8080 9090 # 脚本中获取 port1=$1 # 8080 port2=$2 # 9090 ...

  9. Yii2数据库操作的各种写法

    -------------------------------ActiveRecord---------------------------------------- 查询: // find the ...

  10. Mysql 导入实战

    这个几天公司迁移预览版数据库,当前公司使用的是 Mysql 数据库,版本为 5.6.迁移的数据库大小也不算很大,2G 多一点,总体以小表为主,就几张表数据比较大,有业务记录表达到了 150W 的数量级 ...