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 ...
随机推荐
- 19. Jmeter抓包之浏览器请求
web测试过程中我们经常需要抓包,通常我们使用fiddler或者Charles.但是jmeter也可以抓包,而且非常好用,闲话不多说,下面进入正题.下面用一个例子进行说明 需求:bing首页搜索南京测 ...
- python的浅复制,深复制
1.a = b是将b的id复制给b,然后a与b指向同一个对象 import numpy as np a = np.arange(5) print(a) b = a print(id(a)) print ...
- Chapter03 第三节 浮点数
3.3 浮点数 3.3.1 浮点数的表示 常规表示:12.34.0.01.8.0 E表示: 2.5e+8(2.5 10^8).7E6(7.0 10^6) (e大小写随意) (e+x或者E-x表示小数点 ...
- 【windows】windows安全基础
windows安全基础 安全主体 security principal 是可以进行身份验证的实体. 哪个安全主体在要求访问?这个维度可以是用户,计算机和进程.一旦确认以后,系统就会发放SID. 例子: ...
- 精读《Optional chaining》
1. 引言 备受开发者喜爱的特性 Optional chaining 在 2019.6.5 进入了 stage2,让我们详细读一下草案,了解一下这个特性的用法以及讨论要点. 借着这次精读草案,让我们了 ...
- Java程序的运行过程,以及Java为什么能够跨平台
Java程序运行机制 Java的运行主要分两步:先编译再解释执行 (1)先通过“编译器”将Java源程序(.java)编译成Java字节码文件(.class) (2)通过不同的虚拟机(JVM)将字节 ...
- Java中字母大小写的转换
例:String str = "AbC"; 把字符串所有字母变成小写: System.out.println(str.toLowerCase()); 把字符串所有字母大写: Sys ...
- Ubuntu 安装nodejs最新版本
sudo apt update -y sudo apt install -y npm sudo npm config set registry https://registry.npm.tao ...
- [Git] 025 标签命令
0. 前言 小时候看<剑花-烟雨-江南>,惊讶于那个多重身份的"小侯爷" 后来发现,现实中拥有比小侯爷更多身份的人多如牛毛 其实,在 "Git" 中 ...
- [转帖]Linux shell中2>&1的含义解释 (全网最全,看完就懂)
Linux shell中2>&1的含义解释 (全网最全,看完就懂) https://blog.csdn.net/zhaominpro/article/details/82630528 ...