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之redis

    配置环境变量的命令: 修改环境变量: vim /root/.bash_profile 添加以下配置: export PATH=/server/tools/redis/src:$PATH 激活环境变量 ...

  2. java web项目中引入spring

    自己动手实践了一次,发生中间出了一下问题,现整理出来,供参考. Step1: 新建一个java web项目 Step2:下载spring的jar包http://repo.spring.io/libs- ...

  3. 切片和append操作

    本文转自:http://meia.fun/article/1541470004286 学习切片时,被append这个方法困扰了半天:在main方法中把一个切片作为实参传递给另一个函数,并在这个函数内调 ...

  4. Linux 系统调整内核参数

    调整系统内核参数 内核优化:Linux系统(内核 + shell + 应用程序)       针对业务服务应用而进行的系统内核参数调整(主要是/etc/sysctl.conf文件) 1. vim /e ...

  5. centos7.4应用之KVM

    最小安装系统: 参考博客:https://www.cnblogs.com/chenjiahe/p/5911965.html 辅助命令 yum install make bison flex autom ...

  6. 超强IIS站点工具一键设置PHP,支持多个PHP同时运行

    PHPWAMP8.8.8.8IN支持三大主流Web服务器:iis.apache.nginx NGINX站点管理.IIS站点管理.Apache站点管理均支持php多版本同时运行,无限自定义mysql.p ...

  7. SQL Sever——妙用种子列

    /****** Script for SelectTopNRows command from SSMS ******/ SELECT TOP 1000 [OFFRCD_STATUS_ID] ,[OFF ...

  8. 【C#】#103 动态修改App.config配置文件

    对 C/S模式 下的 App.config 配置文件的AppSetting节点,支持配置信息现改现用,并可以持久保存. 一. 先了解一下如何获取 配置信息里面的内容[获取配置信息推荐使用这个] 1.1 ...

  9. php 中使用cURL发送get/post请求,上传图片,批处理

    cURL是利用url语法规定传输文件和数据的工具.php中有curl拓展,一般用来实现网络抓取,模拟发送get   post请求,文件上传. 在php中建立curl的基本步骤如下: 1 初始化     ...

  10. 3种web会话管理方式

    一.基于server端的session管理 在早期web应用中,通常使用服务端session来管理用户的会话.快速了解服务端session: 1) 服务端session是用户第一次访问应用时,服务器就 ...