springboot shiro token demo实战项目
2019-04-28 本文已影响377人
灰色调诺言
简介
- shiro 是一个强大且易用的Java安全框架,执行身份验证、授权、密码和会话管理。
Git地址
https://gitee.com/wqrzsy/lp-demo/tree/master/lp-springboot-shiro
更多demo请关注
项目分析
1. 自定义权限注解,支持基于注解和配置表多种方式配置过滤规则

注解的使用方式

配置表方式

最后的结果

注意:这里的顺序是配置表的配置会覆盖注解的
2. 抽离Session的缓存实现

3. 封装校验核心逻辑,抽离业务接口

4. InitBean 初始化对象

5. 令牌
用令牌的方式代替JsessionID

6. 配置表
shiro:
session:
# session 超时
outTime: 300000
login:
token:
# 令牌有效时间
expireTime: 300000
password:
# 密码有效时间
expireTime: 300000
# 过滤链
filterChains:
- /**
- anon
logging:
config: classpath:logback-boot.xml
7. 测试
http://localhost:8080/swagger-ui.html
demo项目导入
参考: https://www.jianshu.com/p/cd0275a2f5fb
注意:该DEMO可以作为子项目直接集成在项目中
如果这篇文章对你有帮助请给个star
