13 Spring Boot Shiro使用JS-CSS-IMG
//1.定义ShiroFilterFactoryBean
ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();
factoryBean.setSecurityManager(securityManager);
// 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面
//登录页面(请求)
factoryBean.setLoginUrl("/login");
// 登录成功后要跳转的连接 (请求)
factoryBean.setSuccessUrl("/index");
//没有权限页面
factoryBean.setUnauthorizedUrl("/403");
//.配置拦截器 loadShiroFilterChain(factoryBean);
return factoryBean;
/**
* Shiro 内置过滤器,可以实现权限相关的拦截器
* anon:无需认证(登录)可以直接访问
* authc:必须认证才能访问
* user:如果使用rememberMe的功能才可以访问
* perms:该资源得到资源权限才可以访问
* role:该资源必须得到角色权限才可以访问
*/
filterChainMap.put("/403", "anon");
filterChainMap.put("/assets/**", "anon");
filterChainMap.put("/layui/**", "anon");
filterChainMap.put("/js/**", "anon");
filterChainMap.put("/prism/**", "anon");
/**下面这些规则配置最好配置到配置文件中*/
//LinkedHashMap有序,shiro会根据添加顺序进行拦截
Map<String, String> filterChainMap = new LinkedHashMap<String, String>();
Map<String, String> filterChainMapTemp = new LinkedHashMap<String, String>(); filterChainMap.put("/login", "anon");
filterChainMap.put("/login/check", "anon");
filterChainMap.put("/403", "anon");
filterChainMap.put("/assets/**", "anon");
filterChainMap.put("/layui/**", "anon");
filterChainMap.put("/js/**", "anon");
filterChainMap.put("/prism/**", "anon");
filterChainMap.put("/upload/**", "anon");
//给SpringBootAdmin开启权限
filterChainMap.put("/monitor/**", "anon");
filterChainMap.put("/api/**", "anon");
filterChainMap.put("/health/**", "anon");
filterChainMap.put("/favicon.icon", "anon");
filterChainMap.put("/crm/crmLogin", "anon"); //权限分配
filterChainMap.put("/admin/**", "authc");
filterChainMap.put("/role/**", "authc");
filterChainMap.put("/user/**", "authc");
filterChainMap.put("/dict/**", "authc");
filterChainMap.put("/aop/**", "authc");
filterChainMap.put("/car/**", "authc");
filterChainMap.put("/menu/**", "authc");
filterChainMap.put("/crm/**", "authc"); //行为分配
filterChainMap.put("/notice/notice_create", "authc");
filterChainMap.put("/notice/notice_send", "authc"); //登出的过滤器(自定义退出/logout)
filterChainMap.put("/logout", "logout"); //配置记住我,认证通过才可以访问
filterChainMap.put("/index","user");
filterChainMap.put("/main","user");
//
filterChainMap.put("/**", "authc"); /**
* 为了放行Spring Boot Admin
* 这里启用临时方案 PlanB
* 将shiro倒过来使用
* 所有使用到的页面都加密成需要登陆才能访问
* 其余所有一律采取不拦截
*/
filterChainMapTemp.put("/notice/notice_create", "authc");
filterChainMapTemp.put("/notice/notice_send", "authc");
filterChainMapTemp.put("/js/**", "authc");
filterChainMapTemp.put("/index/**", "authc");
filterChainMapTemp.put("/user/**", "authc");
filterChainMapTemp.put("/dict/**", "authc");
filterChainMapTemp.put("/car/**", "authc");
filterChainMapTemp.put("/aop/**", "authc");
filterChainMapTemp.put("/userinfo/**", "authc");
filterChainMapTemp.put("/calendar/**", "authc");
filterChainMapTemp.put("/admin/**", "authc");
filterChainMapTemp.put("/role/**", "authc");
filterChainMapTemp.put("/menu/**", "authc");
filterChainMapTemp.put("/message/**", "authc");
filterChainMapTemp.put("/notice/**", "authc");
filterChainMapTemp.put("/upload/**", "authc");
filterChainMapTemp.put("/logout", "logout");
filterChainMapTemp.put("/crm/crmLogin", "anon"); filterChainMapTemp.put("/**","anon");
factoryBean.setFilterChainDefinitionMap(filterChainMapTemp);
13 Spring Boot Shiro使用JS-CSS-IMG的更多相关文章
- Spring Boot Shiro 权限管理
Spring Boot Shiro 权限管理 标签: springshiro 2016-01-14 23:44 94587人阅读 评论(60) 收藏 举报 .embody{ padding:10px ...
- Spring Boot Shiro 使用教程
Apache Shiro 已经大名鼎鼎,搞 Java 的没有不知道的,这类似于 .Net 中的身份验证 form 认证.跟 .net core 中的认证授权策略基本是一样的.当然都不知道也没有关系,因 ...
- (39.4) Spring Boot Shiro权限管理【从零开始学Spring Boot】
在读此文章之前您还可能需要先了解: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...
- (39.3) Spring Boot Shiro权限管理【从零开始学Spring Boot】
在学习此小节之前您可能还需要学习: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...
- (39.2). Spring Boot Shiro权限管理【从零开始学Spring Boot】
(本节提供源代码,在最下面可以下载) (4). 集成Shiro 进行用户授权 在看此小节前,您可能需要先看: http://412887952-qq-com.iteye.com/blog/229973 ...
- (39.1) Spring Boot Shiro权限管理【从零开始学Spring Boot】
(本节提供源代码,在最下面可以下载)距上一个章节过了二个星期了,最近时间也是比较紧,一直没有时间可以写博客,今天难得有点时间,就说说Spring Boot如何集成Shiro吧.这个章节会比较复杂,牵涉 ...
- spring boot shiro redis整合基于角色和权限的安全管理-Java编程
一.概述 本博客主要讲解spring boot整合Apache的shiro框架,实现基于角色的安全访问控制或者基于权限的访问安全控制,其中还使用到分布式缓存redis进行用户认证信息的缓存,减少数据库 ...
- Spring Boot Shiro
Shiro 核心 API Subject:用户主体(每次请求都会创建Subject). principal:代表身份.可以是用户名.邮件.手机号码等等,用来标识一个登录主体的身份. credentia ...
- Spring Boot Shiro 权限管理 【转】
http://blog.csdn.net/catoop/article/details/50520958 主要用于备忘 本来是打算接着写关于数据库方面,集成MyBatis的,刚好赶上朋友问到Shiro ...
随机推荐
- 《React+Redux前端开发实战》笔记1:不涉及React项目构建的Hello World案例
本小节实现一个不涉及项目构建的Hello World. [React的第一个Hello World网页] 源码地址:https://jsfiddle.net/allan91/2h1sf0ky/8/ & ...
- 【linux开发】apt源设置
不同的网络状况连接以下源的速度不同, 建议在添加前手动验证以下源的连接速度(ping下就行),选择最快的源可以节省大批下载时间. 首先备份源列表: sudo cp /etc/apt/sources.l ...
- Fabric CA/数字证书管理
MSP(Membership Service Provider)成员管理服务提供商 名词: 1.CSR(Cerificate Signing Request):证书签署请求文件 CSR里包含申请者的 ...
- ant buid.xml 模板
<?xml version="1.0" encoding="UTF-8"?> <project name="ant" de ...
- Java常用的日志框架
1.Java常用日志框架对比 https://www.jianshu.com/p/bbbdcb30bba8 2.Log4j,Log4j2,Logback日志框架性能对比 https://bbs.hua ...
- 通过Spark Streaming处理交易数据
Apache Spark 是加州大学伯克利分校的 AMPLabs 开发的开源分布式轻量级通用计算框架. 由于 Spark 基于内存设计,使得它拥有比 Hadoop 更高的性能(极端情况下可以达到 10 ...
- Ubuntu终端路径和文件夹相互切换
一. 环境配置 1. 打开终端输入安装命令 sudo apt-get install nautilus-open-terminal 2. 重新加载文件管理器 nautilus -q 3. 重启电脑 s ...
- python 如何解决高并发下的库存问题??
python 提供了2种方法解决该问题的问题:1,悲观锁:2,乐观锁 悲观锁:在查询商品储存的时候加锁 select_for_update() 在发生事务的commit或者是事务的rollback时 ...
- python中session的使用
- vue脚手架通过UI界面创建项目
vue脚手架提供了图形界面操作项目,比之前通过命令操作的形式还要简单,以下是使用的步骤: 1.全局安装@vue/cli脚手架工具 npm i @vue/cli -g {使用淘宝镜像:npm insta ...