Shiro主要是通过URL过滤来进行安全管理,这里的配置便是指定具体授权规则定义。

Xml代码  
  1. <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
  2. <property name="securityManager" ref="securityManager"/>
  3. <property name="loginUrl" value="/login.jsp"/>
  4. <property name="successUrl" value="/home.jsp"/>
  5. <property name="unauthorizedUrl" value="/unauthorized.jsp"/> -->
  6. <property name="filterChainDefinitions">
  7. <value>
  8. # some example chain definitions:
  9. /admin/** = authc, roles[admin]
  10. /docs/** = authc, perms[document:read]
  11. /** = authc
  12. # more URL-to-FilterChain definitions here
  13. </value>
  14. </property>
  15. </bean>

URL过滤器配置说明: 
Shiro可以通过配置文件实现基于URL的授权验证。FilterChain定义格式: 
URL_Ant_Path_Expression = Path_Specific_Filter_Chain 
每个URL配置,表示匹配该URL的应用程序请求将由对应的过滤器进行验证。 
例如: 
[urls] 
/index.html = anon 
/user/create = anon 
/user/** = authc 
/admin/** = authc, roles[administrator] 
/rest/** = authc, rest 
/remoting/rpc/** = authc, perms["remote:invoke"]

URL表达式说明 
1、URL目录是基于HttpServletRequest.getContextPath()此目录设置 
2、URL可使用通配符,**代表任意子目录 
3、Shiro验证URL时,URL匹配成功便不再继续匹配查找。所以要注意配置文件中的URL顺序,尤其在使用通配符时。

Filter Chain定义说明 
1、一个URL可以配置多个Filter,使用逗号分隔 
2、当设置多个过滤器时,全部验证通过,才视为通过 
3、部分过滤器可指定参数,如perms,roles

Shiro内置的FilterChain

Filter Name Class
anon org.apache.shiro.web.filter.authc.AnonymousFilter
authc org.apache.shiro.web.filter.authc.FormAuthenticationFilter
authcBasic org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter
perms org.apache.shiro.web.filter.authz.PermissionsAuthorizationFilter
port org.apache.shiro.web.filter.authz.PortFilter
rest org.apache.shiro.web.filter.authz.HttpMethodPermissionFilter
roles org.apache.shiro.web.filter.authz.RolesAuthorizationFilter
ssl org.apache.shiro.web.filter.authz.SslFilter
user org.apache.shiro.web.filter.authc.UserFilter

shiro配置说明的更多相关文章

  1. Apache Shiro 使用手册(五)Shiro 配置说明

    Apache Shiro的配置主要分为四部分:  对象和属性的定义与配置 URL的过滤器配置 静态用户配置 静态角色配置 其中,由于用户.角色一般由后台进行操作的动态数据,因此Shiro配置一般仅包含 ...

  2. Apache Shiro 使用手册(五)Shiro 配置说明(转发:http://kdboy.iteye.com/blog/1169637)

    Apache Shiro的配置主要分为四部分: 对象和属性的定义与配置 URL的过滤器配置 静态用户配置 静态角色配置 其中,由于用户.角色一般由后台进行操作的动态数据,因此Shiro配置一般仅包含前 ...

  3. Apache Shiro 手册

    (一)Shiro架构介绍 一.什么是Shiro Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理等功能: 认证 - 用户身份识别,常被称为用户"登录 ...

  4. Apache Shiro 使用手册---转载

    原文地址:http://www.360doc.com/content/12/0104/13/834950_177177202.shtml (一)Shiro架构介绍 一.什么是Shiro Apache ...

  5. Apache Shiro 使用手册

    http://kdboy.iteye.com/blog/1154644 (一)Shiro架构介绍 一.什么是Shiro  Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加 ...

  6. Apache Shiro 使用手冊 链接文件夹整理

    1.Apache Shiro 使用手冊(一)Shiro架构介绍 2.Apache Shiro 使用手冊(二)Shiro 认证 3.Apache Shiro 使用手冊(三)Shiro 授权 4.Apac ...

  7. 将 Shiro 作为应用的权限基础 四:shiro的配置说明

    Apache Shiro的配置主要分为四部分: SecurityManager的配置 URL过滤器的配置 静态用户配置 静态角色配置 其中,由于用户.角色一般由后台进行操作的动态数据,比如通过@Req ...

  8. SpringMVC整合Shiro——(3)

    SpringMVC整合Shiro,Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理等功能. 第一步:配置web.xml <!-- 配置Shiro过滤器,先让Shiro ...

  9. Shiro学习详解

    1.Shiro基本架构 一.什么是Shiro Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理等功能: 认证 - 用户身份识别,常被称为用户“登录”: 授权 ...

随机推荐

  1. linux ubuntu 本地镜像 软件源 制作方法

    1.配置当前软件源,镜像非常大,所以首先要配置一下载速度快的软件源http://fffo.blog.163.com/blog/static/2119130682014322104136601/2.安装 ...

  2. Oracle EBS 报错:此责任无可用函数。 更改责任或与您的系统管理员联系。

    解决:修改配置文件        1.FND: Diagnostics (FND:诊断)            启用设为”是”        2.Utilities:Diagnostics (公用程序 ...

  3. Redis学习---Ubuntu下Redis的安装

    Ubuntu系统安装 Linux 系统安装[Ubuntu] 安装/启动Redis 要在 Ubuntu 上安装 Redis,打开终端,然后输入以下命令: 升级软件管理模块apt: sudo apt-ge ...

  4. Linux 隐藏系统信息

    Linux查看系统信息 [更多参考]https://www.cnblogs.com/ftl1012/p/uname.html Linux隐藏系统信息 查看: cat /etc/issue.net    ...

  5. Apache下开启SSI配置,使html支持include包含

    有的时候,我们的页面有公共的导航栏navbar,公共的脚注footer,那么我们就想把这些公共部分独立成一个html文件,在要引用的地方像引用js,css一样,给包含进来. Apache下开启SSI配 ...

  6. session过期,拦截ajax请求并跳转登录页面

    1.方法一 :1.1使用filter 和ajaxsetup 对ajax进行拦截并跳转登录页面 public void doFilter(ServletRequest request, ServletR ...

  7. 1101: [POI2007]Zap

    Description FGD正在破解一段密码,他需要回答很多类似的问题:对于给定的整数a,b和d,有多少正整数对x,y,满足x<=a ,y<=b,并且gcd(x,y)=d.作为FGD的同 ...

  8. 【转】 Android应用内多进程分析和研究

    正常情况下,一个apk启动后只会运行在一个进程中,其进程名为AndroidManifest.xml文件中指定的应用包名,所有的基本组件都会在这个进程中运行.但是如果需要将某些组件(如Service.A ...

  9. mongodb的学习-2-简介

    http://www.runoob.com/mongodb/mongodb-intro.html 什么是MongoDB ? MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系 ...

  10. [转]DirectX and .NET[英]

    With the DirectX SDK (June 2010) release and the addition of support for Visual Studio 2010, I’ve be ...