Apache shiro为java的一个安全框架,使用简单,直观,实现 用户认证、用户授权。
使用流程:
一、web.xml中设置shiroFilter过滤器,按照shiro配置文件中的设置完成权限过滤
二、配置shiro配置文件
1、配置securityManager,安全机制管理器,securityManager中主要包含
authenticator(认证器:登录账号主体认证)、
authorizer(授权器:获取当前账号对应资源权限信息)、
sessionManager(session管理器、一般web容器有自己的一套session管理机制,用web自己的)、
sessionDAO(sessionManager依赖其对session进行增删改查管理)、
cacheManager(缓存管理:通常使用ehcache来管理缓存,ehcache轻量、简便、使用容易、由于缓存在jvm中所以快速,但不方便实现分布式缓存)
realm(用于实现数据获取,是authorizer、authenticator与数据之间的桥梁),个人使用中重写了realm类,对里面获取用户登录认证信息(doGetAuthenticationInfo)、用户权限信息(doGetAuthorizationInfo)方法进行了重写
2、配置filterChainDefinitions,定义系统基本权限过滤,以及与之对应的filter

常用的权限:
anno不拦截;
user针对用户登录信息拦截;
role针对用户角色拦截;
自定义拦截规则,在filter中配置上自定义拦截filter
附:
1、shiro原理及其运行流程:https://blog.csdn.net/mine_song/article/details/61616259
2、shiroFilter配置详解:https://blog.csdn.net/zhangcc233/article/details/80591769
3、shiro与spring security对比:https://blog.csdn.net/liyuejin/article/details/77838868
4、spring security简介:https://blog.csdn.net/xlecho/article/details/80026527
浙公网安备 33010602011771号