Shiro入门推荐及认证和登录流程分析
前言
近期因为面试被问到了权限管理这块,所以趁机了解下Shiro。Shiro既可支持普通Java项目,也能支持普通Web项目,还可以支持Spring Web项目。相比Spring Security来说,Shiro还是比较简单的。以下的分析以普通Web项目为例
Shiro入门推荐
shiro的官网有些文章已经过时了,如http://shiro.apache.org/webapp-tutorial.html这里,Stormpath都已经关闭了。入门的话,推荐慕课网的视频https://www.imooc.com/learn/977,大概一个小时。之后再看看官网文章,动手写个web集成、自定义Realm啥的即可,其他需要的时候再研究就行了
Web项目集成Shiro
pom.xml添加依赖(如果不打日志和单元测试,log和junit可以不加)
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.13.3</version>