shrio 权限管理filterChainDefinitions过滤器配置(转)
/**
* 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
有两种方式实现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>
shrio 权限管理filterChainDefinitions过滤器配置(转)的更多相关文章
- shrio 权限管理filterChainDefinitions过滤器配置
/** * Shiro-1.2.2内置的FilterChain * @see ============================================================= ...
- shrio 权限管理filterChainDefinitions过滤器配置(转)
/** * Shiro-1.2.2内置的FilterChain * @see ============================================================= ...
- Shiro 权限管理filterChainDefinitions过滤器配置
博客转载:http://blog.csdn.net/userrefister/article/details/47807075 /** * Shiro-1.2.2内置的FilterChain * @s ...
- xml配置文件中对于Shiro 权限管理filterChainDefinitions过滤器配置
博客转载:http://blog.csdn.net/userrefister/article/details/47807075 /** * Shiro-1.2.2内置的FilterChain * @s ...
- 【权限管理】springboot集成security
摘自: https://www.cnblogs.com/hhhshct/p/9726378.html https://blog.csdn.net/weixin_42849689/article/det ...
- 上帝的归上帝,凯撒的归凯撒—— CODING 权限管理更新
上帝的归上帝,凯撒的归凯撒 <马太福音>22 章 15-22 节,耶稣用这句话,说明了神权与政权之间的正确关系,奠定了神权与政权的基础,也划清了二者的界限.其实这两个问题如今也依旧出现在公 ...
- HADOOP docker(七):hive权限管理
1. hive权限简介1.1 hive中的用户与组1.2 使用场景1.3 权限模型1.3 hive的超级用户2. 授权管理2.1 开启权限管理2.2 实现超级用户2.3 实现hiveserver2用户 ...
- Spring Boot集成Shrio实现权限管理
Spring Boot集成Shrio实现权限管理 项目地址:https://gitee.com/dsxiecn/spring-boot-shiro.git Apache Shiro是一个强大且 ...
- springBoot2.0 配置shiro实现权限管理
一.前言 基于上一篇springBoot2.0 配置 mybatis+mybatisPlus+redis 这一篇加入shiro实现权限管理 二.shiro介绍 2.1 功能特点 Shiro 包含 10 ...
随机推荐
- 73.node.js开发错误——TypeError: Cannot set property 'XXX' of undefined
转自:https://blog.csdn.net/fd214333890/article/details/53467429
- vue -- config index.js 配置文件详解
此文章介绍vue-cli脚手架config目录下index.js配置文件 此配置文件是用来定义开发环境和生产环境中所需要的参数 关于注释 当涉及到较复杂的解释我将通过标识的方式(如(1))将解释写到单 ...
- python2 python3 m2crypto 安装(rsa 私钥文件加密)
转自作者:大道至简_Andy 原文链接:https://www.jianshu.com/p/b308357ef649 第一种方式:使用apt-get(以Python2版本进行测试的) sudo apt ...
- 【2017 Multi-University Training Contest - Team 3】Kanade's sum
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=6058 [Description] 给你n个数; 它们是由(1..n)组成的排列; 然后给你一个数字 ...
- 阿里云 django的一次web维护记录
首先, 丢给我一个阿里云的server的账号/password,之前没有玩过阿里云,想想应该也是ssh服务来远程登陆. 环境: centos+nginx+uwsgi+python2.7+django. ...
- win7-时间更新
今天发现电脑的时间不对,后来就自己摸索了时间的自动更新方法.自己记录下来,以方便以后忘了查询 点击电脑右下角的时间->选择更改日期和时间设置->选择internet->更改设置-&g ...
- Cookie应用--显示看过的商品
package cn.itcast; import java.io.IOException; import java.io.PrintWriter; import java.util.LinkedHa ...
- 升级你的Linux日志系统
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" ...
- C# Unity依赖注入利用Attribute实现AOP功能
使用场景? 很多时候, 我们定义一个功能, 当我们要对这个功能进行扩展的时候, 按照常规的思路, 我们一般都是利用OOP的思想, 在原有的功能上进行扩展. 那么有没有一种东西, 可以实现当我们需要扩展 ...
- 深入理解HTTP协议及原理分析之缓存(3种缓存机制)
3.2 缓存的实现原理 3.2.1什么是Web缓存 WEB缓存(cache)位于Web服务器和客户端之间. 缓存会根据请求保存输出内容的副本,例如html页面,图片,文件,当下一个请求来到的时候:如果 ...