shiro
一、什么是shiro?
shiro是一个java的安全框架、Apache的一个开源框架。简单易用
二、实现的功能:
认证、授权、会话管理和密码加密等
Authentication:认证
Authorization:授权
Session Management:session会话管理
Cryptography:密码加密
Caching:缓存
web Support:web支持
Concurrency:多线程、并发
Testing:测试
Run as:以某种身份运行
Remember Me:记住我
1.所需要jar包
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.22.RELEASE</version>
</dependency>
<!--
springboot-starter-web
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.22.RELEASE</version>
</dependency>
<!--
springboot-mybatis整合包
-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<!--
mysql的驱动包
-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!--
druid连接池
-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
<!--
html的thymeleaf模板
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>1.5.10.RELEASE</version>
</dependency>
<!--
fastjson包
-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.1</version>
</dependency>
<!--
添加springboot的进程jar包
里面包含了properties文件的读取(其实就是包含了@ConfigurationProperties()注解)
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>1.5.22.RELEASE</version>
<optional>true</optional>
</dependency>
<!--
shiro和each的缓存包
-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>1.2.5</version>
</dependency>
<!--
shiro和springboot的整合包
-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.2.5</version>
</dependency>
<!--
在thymeleaf模板中使用shiro的标签
-->
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.21</version>
</dependency>
</dependencies>
2.实现层级依赖
shiro-model:不需要依赖任何项目
shiro-mapper:依赖于model
shiro-service:依赖于mapper
shiro-web:依赖于service,依赖于kernel
shiro-kernel:依赖于service
3.需求
当认证成功后会自动跳转到项目的根目录"/"
index页面有菜单
图书管理
学生管理
用户管理
垃圾分类管理
根据当前所登录的用户所拥有的角色来进行显示菜单
user--->user_manager--->只会显示用户管理,其他菜单不显示
Last:
shiro认证流程: