mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-02-27 16:50:24 +08:00
Compare commits
15 Commits
v1.16.0
...
v1.16.0.RE
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8f9aafe37 | ||
|
|
7d985602c5 | ||
|
|
dca7830f1b | ||
|
|
a4ae818376 | ||
|
|
740ad2e132 | ||
|
|
78b3ba8bfb | ||
|
|
40fc0810dd | ||
|
|
be2258ee1d | ||
|
|
b1413a3436 | ||
|
|
9c467793f0 | ||
|
|
985eaac79a | ||
|
|
98f94c8b97 | ||
|
|
b66919276d | ||
|
|
38bfb45b26 | ||
|
|
094f8eb3ae |
@@ -45,8 +45,10 @@ sa-token是一个轻量级Java权限认证框架,主要解决:登录认证
|
||||
- **权限验证** —— 适配RBAC权限模型,不同角色不同授权
|
||||
- **Session会话** —— 专业的数据缓存中心
|
||||
- **踢人下线** —— 将违规用户立刻清退下线
|
||||
- **账号封禁** —— 封禁指定账号,使其无法登陆,还可指定解封时间
|
||||
- **持久层扩展** —— 可集成Redis、Memcached等专业缓存中间件,重启数据不丢失
|
||||
- **分布式会话** —— 提供jwt集成和共享数据中心两种分布式会话方案
|
||||
- **微服务网关鉴权** —— 适配Gateway、Soul、Zuul等常见网关组件的请求拦截认证
|
||||
- **单点登录** —— 一处登录,处处通行
|
||||
- **模拟他人账号** —— 实时操作任意用户状态数据
|
||||
- **临时身份切换** —— 将会话身份临时切换为其它账号
|
||||
@@ -60,7 +62,7 @@ sa-token是一个轻量级Java权限认证框架,主要解决:登录认证
|
||||
- **会话治理** —— 提供方便灵活的会话查询接口
|
||||
- **记住我模式** —— 适配[记住我]模式,重启浏览器免验证
|
||||
- **密码加密** —— 提供密码加密模块,可快速MD5、SHA1、SHA256、AES、RSA加密
|
||||
- **组件自动注入** —— 零配置与Spring等框架集成
|
||||
- **开箱即用** —— 提供SpringMVC、WebFlux等常见web框架starter集成包,真正的开箱即用
|
||||
- **更多功能正在集成中...** —— 如有您有好想法或者建议,欢迎加群交流
|
||||
|
||||
|
||||
@@ -144,6 +146,7 @@ sa-token秉承着开放的思想,欢迎大家为框架添砖加瓦:
|
||||
|
||||
[**[ jthink]** 一个基于springboot+sa-token+thymeleaf的博客系统](https://gitee.com/wtsoftware/jthink)
|
||||
|
||||
|
||||
如果您的项目使用了sa-token,欢迎提交pr
|
||||
|
||||
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -8,7 +8,7 @@
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
|
||||
<!-- 项目介绍 -->
|
||||
<name>sa-token</name>
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
<!-- 一些属性 -->
|
||||
<properties>
|
||||
<sa-token-version>1.16.0</sa-token-version>
|
||||
<sa-token-version>1.16.0.RELEASE</sa-token-version>
|
||||
<jdk.version>1.8</jdk.version>
|
||||
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>utf-8</project.reporting.outputEncoding>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class SaTokenConsts {
|
||||
/**
|
||||
* sa-token 当前版本号
|
||||
*/
|
||||
public static final String VERSION_NO = "v1.16.0";
|
||||
public static final String VERSION_NO = "v1.16.0.RELEASE";
|
||||
|
||||
/**
|
||||
* sa-token 开源地址
|
||||
@@ -23,7 +23,7 @@ public class SaTokenConsts {
|
||||
/**
|
||||
* sa-token 开发文档地址
|
||||
*/
|
||||
public static final String DEV_DOC_URL = "http://sa-token.dev33.cn/";
|
||||
public static final String DEV_DOC_URL = "http://sa-token.dev33.cn";
|
||||
|
||||
// =================== 常量key标记 ===================
|
||||
|
||||
|
||||
@@ -19,9 +19,12 @@ public class SaTokenInsideUtil {
|
||||
*/
|
||||
public static void printSaToken() {
|
||||
String str = "____ ____ ___ ____ _ _ ____ _ _ \r\n" + "[__ |__| __ | | | |_/ |___ |\\ | \r\n"
|
||||
+ "___] | | | |__| | \\_ |___ | \\| \r\n" + "sa-token:" + SaTokenConsts.VERSION_NO
|
||||
// + " \r\n" + "DevDoc:" + SaTokenConsts.DEV_DOC_URL // + "\r\n";
|
||||
+ " \r\n" + "GitHub:" + SaTokenConsts.GITHUB_URL; // + "\r\n";
|
||||
+ "___] | | | |__| | \\_ |___ | \\| "
|
||||
// + "sa-token:"
|
||||
+ "\r\n" + "DevDoc:" + SaTokenConsts.DEV_DOC_URL // + "\r\n";
|
||||
+ " (" + SaTokenConsts.VERSION_NO + ")"
|
||||
+ "\r\n" + "GitHub:" + SaTokenConsts.GITHUB_URL // + "\r\n";
|
||||
;
|
||||
System.out.println(str);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<!-- sa-token-spring-boot-starter -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<artifactId>sa-token-core</artifactId>
|
||||
<version>${sa-token-version}</version>
|
||||
</dependency>
|
||||
<!-- RedisTemplate 相关操作API -->
|
||||
@@ -28,6 +28,13 @@
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
</dependency>
|
||||
<!-- jackson-databind -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.11.2</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import cn.dev33.satoken.util.SaTokenInsideUtil;
|
||||
public class SaTokenDaoRedisJackson implements SaTokenDao {
|
||||
|
||||
/**
|
||||
* ObjectMapper对象 (以public作用于暴露出此对象,方便开发者二次更改配置)
|
||||
* ObjectMapper对象 (以public作用域暴露出此对象,方便开发者二次更改配置)
|
||||
*/
|
||||
public ObjectMapper objectMapper;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<!-- sa-token-spring-boot-starter -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<artifactId>sa-token-core</artifactId>
|
||||
<version>${sa-token-version}</version>
|
||||
</dependency>
|
||||
<!-- RedisTemplate 相关操作API -->
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<!-- 定义sa-token版本号 -->
|
||||
<properties>
|
||||
<sa-token-version>1.16.0</sa-token-version>
|
||||
<sa-token-version>1.16.0.RELEASE</sa-token-version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -2,16 +2,16 @@ package com.pj.satoken.jwt;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import cn.dev33.satoken.SaTokenManager;
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.context.model.SaStorage;
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
@@ -122,15 +122,15 @@ public class SaTokenJwtUtil {
|
||||
|
||||
// 重写 (在当前会话上登录id )
|
||||
@Override
|
||||
public void setLoginId(Object loginId, String device) {
|
||||
public void setLoginId(Object loginId, SaLoginModel loginModel) {
|
||||
// ------ 1、获取相应对象
|
||||
HttpServletRequest request = SaTokenManager.getSaTokenServlet().getRequest();
|
||||
SaStorage storage = SaTokenManager.getSaTokenContext().getStorage();
|
||||
SaTokenConfig config = getConfig();
|
||||
// ------ 2、生成一个token
|
||||
String tokenValue = createTokenValue(loginId);
|
||||
request.setAttribute(splicingKeyJustCreatedSave(), tokenValue); // 将token保存到本次request里
|
||||
storage.set(splicingKeyJustCreatedSave(), tokenValue); // 将token保存到本次request里
|
||||
if(config.getIsReadCookie() == true){ // cookie注入
|
||||
SaTokenManager.getSaTokenCookie().addCookie(SaTokenManager.getSaTokenServlet().getResponse(), getTokenName(), tokenValue, "/", config.getCookieDomain(), (int)config.getTimeout());
|
||||
SaTokenManager.getSaTokenContext().getResponse().addCookie(getTokenName(), tokenValue, "/", config.getCookieDomain(), (int)config.getTimeout());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class SaTokenJwtUtil {
|
||||
}
|
||||
// 如果打开了cookie模式,把cookie清除掉
|
||||
if(getConfig().getIsReadCookie() == true){
|
||||
SaTokenManager.getSaTokenCookie().delCookie(SaTokenManager.getSaTokenServlet().getRequest(), SaTokenManager.getSaTokenServlet().getResponse(), getTokenName());
|
||||
SaTokenManager.getSaTokenContext().getResponse().deleteCookie(getTokenName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<java.version>1.8</java.version>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
<!-- 定义sa-token版本号 -->
|
||||
<sa-token-version>1.16.0</sa-token-version>
|
||||
<sa-token-version>1.15.0.RELEASE</sa-token-version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<java.version>1.8</java.version>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
<!-- 定义sa-token版本号 -->
|
||||
<sa-token-version>1.16.0</sa-token-version>
|
||||
<sa-token-version>1.15.0.RELEASE</sa-token-version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<!-- 定义sa-token版本号 -->
|
||||
<properties>
|
||||
<sa-token-version>1.16.0</sa-token-version>
|
||||
<sa-token-version>1.16.0.RELEASE</sa-token-version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<!-- 定义sa-token版本号 -->
|
||||
<properties>
|
||||
<sa-token-version>1.16.0</sa-token-version>
|
||||
<sa-token-version>1.16.0.RELEASE</sa-token-version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -143,6 +143,7 @@ sa-token秉承着开放的思想,欢迎大家为框架添砖加瓦:
|
||||
|
||||
## 使用sa-token的开源项目
|
||||
[**[ sa-plus]** 一个基于springboot架构的快速开发框架,内置代码生成器](https://gitee.com/click33/sa-plus)
|
||||
|
||||
[**[ jthink]** 一个基于springboot+sa-token+thymeleaf的博客系统](https://gitee.com/wtsoftware/jthink)
|
||||
|
||||
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
<!-- 这是目录树文件 -->
|
||||
|
||||
- **开始**
|
||||
- [框架](/README)
|
||||
- [介绍](/README)
|
||||
- [集成](/start/download)
|
||||
- [在SpringBoot环境集成](/start/example)
|
||||
- [在WebFlux环境集成](/start/webflux-example)
|
||||
|
||||
- **使用**
|
||||
- **基础**
|
||||
- [登录验证](/use/login-auth)
|
||||
- [权限验证](/use/jur-auth)
|
||||
- [Session会话](/use/session)
|
||||
- [踢人下线](/use/kick)
|
||||
- [持久层扩展(集成Redis)](/use/dao-extend)
|
||||
- [无Cookie模式(前后台分离)](/use/not-cookie)
|
||||
- [模拟他人](/use/mock-person)
|
||||
- [同端互斥登录](/use/mutex-login)
|
||||
- [注解式鉴权](/use/at-check)
|
||||
- [路由拦截式鉴权](/use/route-check)
|
||||
- [全局过滤器](/use/global-filter)
|
||||
- [框架配置](/use/config)
|
||||
|
||||
- **深入**
|
||||
- [持久层扩展(集成Redis)](/use/dao-extend)
|
||||
- [无Cookie模式(前后台分离)](/use/not-cookie)
|
||||
- [花式token](/use/token-style)
|
||||
- [Token前缀](/use/token-prefix)
|
||||
- [框架配置](/use/config)
|
||||
- [会话治理](/use/search-session)
|
||||
- [记住我模式](/use/remember-me)
|
||||
- [模拟他人 & 身份切换](/use/mock-person)
|
||||
- [同端互斥登录](/use/mutex-login)
|
||||
- [密码加密](/use/password-secure)
|
||||
- [会话治理](/use/search-session)
|
||||
|
||||
- **进阶**
|
||||
- [全局过滤器](/use/global-filter)
|
||||
- [集群、分布式](/senior/dcs)
|
||||
- [单点登录](/senior/sso)
|
||||
- [多账号验证](/use/many-account)
|
||||
@@ -42,6 +44,7 @@
|
||||
- [Session模型详解](/fun/session-model)
|
||||
- [TokenInfo参数详解](/fun/token-info)
|
||||
- [框架源码所有技术栈](/fun/tech-stack)
|
||||
<!-- - [Sa-Token大事记](/fun/timeline) -->
|
||||
|
||||
|
||||
|
||||
|
||||
14
sa-token-doc/doc/fun/timeline.md
Normal file
14
sa-token-doc/doc/fun/timeline.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Sa-Token 大事记
|
||||
|
||||
|
||||
- **2020-02-04:** 在GitHub提交第一个版本,正式开源
|
||||
- **2020-09-14:** GitHub star数量破100
|
||||
- **2020-10-26:** Gitee star数量破100
|
||||
- **2021-03-01:** 被[HelloGitHub]第59期收录推荐
|
||||
- **2021-03-26:** GitHub star数量破1k
|
||||
- **2021-03-30:** 受TLog作者邀请,sa-token加入dromara社区
|
||||
- **2021-03-30:** 被Gitee官方列为推荐项目
|
||||
- **2021-03-31:** Gitee star数量破1K
|
||||
- **2021-04-09:** GitHub star数量破2K
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
## Maven依赖
|
||||
在项目中直接通过 `pom.xml` 导入 `sa-token` 的依赖即可:
|
||||
|
||||
<!-- tabs:start -->
|
||||
<!------------------------------ tabs:start ------------------------------>
|
||||
<!-- tab:SpringMVC环境 (ServletAPI) -->
|
||||
``` xml
|
||||
<!-- sa-token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -23,10 +23,32 @@
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-reactor-spring-boot-starter</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
<!-- tabs:end -->
|
||||
|
||||
<!-- tab:Servlet容器环境 -->
|
||||
注:如果你的项目没有使用Spring,但是Web框架是基于`ServletAPI`规范的,可以引入此包
|
||||
``` xml
|
||||
<!-- sa-token 权限认证(ServletAPI规范), 在线文档:http://sa-token.dev33.cn/ -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-servlet</artifactId>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
<!-- tab:其它 -->
|
||||
注:如果你的项目既没有使用`SpringMVC`、`WebFlux`,也不是基于`ServletAPI`规范,那么可以引入`core`核心包
|
||||
``` xml
|
||||
<!-- sa-token 权限认证(core核心包), 在线文档:http://sa-token.dev33.cn/ -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-core</artifactId>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
<!---------------------------- tabs:end ------------------------------>
|
||||
|
||||
|
||||
|
||||
@@ -34,19 +56,27 @@
|
||||
<!-- tabs:start -->
|
||||
<!-- tab:SpringMVC环境 (ServletAPI) -->
|
||||
``` xml
|
||||
implementation 'cn.dev33:sa-token-spring-boot-starter:1.16.0'
|
||||
implementation 'cn.dev33:sa-token-spring-boot-starter:1.16.0.RELEASE'
|
||||
```
|
||||
<!-- tab:WebFlux环境 (Reactor) -->
|
||||
``` xml
|
||||
implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:1.16.0'
|
||||
implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:1.16.0.RELEASE'
|
||||
```
|
||||
<!-- tab:Servlet容器环境 -->
|
||||
``` xml
|
||||
implementation 'cn.dev33:sa-token-servlet:1.16.0.RELEASE'
|
||||
```
|
||||
<!-- tab:其它 -->
|
||||
``` xml
|
||||
implementation 'cn.dev33:sa-token-core:1.16.0.RELEASE'
|
||||
```
|
||||
<!-- tabs:end -->
|
||||
|
||||
|
||||
## 获取源码
|
||||
如果你想深入了解`sa-token`,你可以通过`github`或者`gitee`来获取源码 (**学习测试请拉取master分支**,dev为正在开发的分支,有很多特性并不稳定)
|
||||
- github地址:[https://github.com/dromara/sa-token](https://github.com/dromara/sa-token)
|
||||
如果你想深入了解`sa-token`,你可以通过`gitee`或者`github`来获取源码 (**学习测试请拉取master分支**,dev为正在开发的分支,有很多特性并不稳定)
|
||||
- gitee地址:[https://gitee.com/dromara/sa-token](https://gitee.com/dromara/sa-token)
|
||||
- github地址:[https://github.com/dromara/sa-token](https://github.com/dromara/sa-token)
|
||||
- 开源不易,求鼓励,给个`star`吧
|
||||
- 源码目录介绍:
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ WebFlux基于Reactor响应式模型开发,有着与标准ServletAPI完全不
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-reactor-spring-boot-starter</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ sa-token内置两种模式完成注解鉴权,分别是`AOP模式`和`拦截器
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-aop</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Sa-token默认将会话数据保存在内存中,此模式读写速度最快,
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-dao-redis</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
优点:兼容性好,缺点:Session序列化后基本不可读,对开发者来讲等同于乱码
|
||||
@@ -26,7 +26,7 @@ Sa-token默认将会话数据保存在内存中,此模式读写速度最快,
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
优点:Session序列化后可读性强,可灵活手动修改,缺点:兼容性稍差
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
### 组件简述
|
||||
|
||||
上一节,我们学习了“根据拦截器实现路由拦截鉴权”,其实在大多数web框架中,使用过滤器可以实现同样的功能,本章我们就利用sa-token全局过滤器来实现路由拦截器鉴权。
|
||||
之前的章节中,我们学习了“根据拦截器实现路由拦截鉴权”,其实在大多数web框架中,使用过滤器可以实现同样的功能,本章我们就利用sa-token全局过滤器来实现路由拦截器鉴权。
|
||||
|
||||
首先我们先梳理清楚一个问题,既然拦截器已经可以实现路由鉴权,为什么还要用过滤器再实现一遍呢?简而言之:
|
||||
1. 相比于拦截器,过滤器更加底层,执行时机更靠前,有利于防渗透扫描
|
||||
|
||||
@@ -52,4 +52,8 @@ StpUtil.untieDisable(10001);
|
||||
StpUtil.logoutByLoginId(10001);
|
||||
// 再封禁账号
|
||||
StpUtil.disableLoginId(10001, 86400);
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
> 如果想管理当前账号的session怎么办? 请参考:[Session会话](/use/session)
|
||||
> 如果想查询所有账号的session怎么办? 请参考:[会话治理](/use/search-session)
|
||||
@@ -45,3 +45,4 @@ for (String token : tokenList) {
|
||||
请根据业务实际水平合理调用API
|
||||
|
||||
|
||||
> 如果需要实时获取当前登录人数或者需要在用户退出后自动触发某事件等, 建议采用websocket技术
|
||||
@@ -159,3 +159,7 @@ public void reset(HttpSession session) {
|
||||
**要点:**
|
||||
1. `SaSession` 与 `HttpSession` 没有任何关系,在`HttpSession`上写入的值,在`SaSession`中无法取出
|
||||
2. `HttpSession`并未被框架接管,在使用sa-token时,请在任何情况下均使用`SaSession`,不要使用`HttpSession`
|
||||
|
||||
|
||||
> 如果想管理其他账号的session怎么办? 请参考:[踢人下线](/use/kick)
|
||||
> 如果想查询所有账号的session怎么办? 请参考:[会话治理](/use/search-session)
|
||||
@@ -59,7 +59,7 @@ body{font-size: 16px; color: #34495E; font-family: "Source Sans Pro","Helvetica
|
||||
.feature-z{color: rgb(128, 128, 128); text-align: center; box-sizing: border-box; line-height: 24px; font-size: 16px;}
|
||||
|
||||
.feature-box{margin-top: 40px; margin-bottom: 60px; display: flex; flex-wrap: wrap; justify-content: flex-start;}
|
||||
.feature{border: 0px #000 solid; flex: 1; min-width: 33%; max-width: 33%; text-align: left; padding: 1.5em; box-sizing: border-box;}
|
||||
.feature{border: 0px #000 solid; flex: 1; min-width: 33%; max-width: 33%; text-align: left; padding: 1.5em 1.2em; box-sizing: border-box;}
|
||||
.feature h2{font-size: 24px; color: #000; font-weight: 400;}
|
||||
.feature p{margin-top: 14px; font-size: 16px; color: #4e6e8e;}
|
||||
|
||||
@@ -70,7 +70,8 @@ body{font-size: 16px; color: #34495E; font-family: "Source Sans Pro","Helvetica
|
||||
.com-box a{flex: 1; display: block; cursor: pointer; border: 0px #ddd solid;}
|
||||
.com-box a{min-width: 17%; max-width: 18%; margin: 5px; line-height: 100px;}
|
||||
.com-box a img{transition: all 0.2s; vertical-align: middle; min-width: 60%; max-width: 100%; max-height: 100%;}
|
||||
.com-box a:hover img{transform: scale(1.05, 1.05);}
|
||||
.com-box a img:hover{transform: scale(1.05, 1.05);}
|
||||
.com-box-you a img:hover{transform: none;}
|
||||
|
||||
/* -------- 友情链接 --------- */
|
||||
.com-box-you a{min-width: 13%; max-width: 14%; line-height: 60px; height: 60px; margin: 10px;}
|
||||
@@ -100,10 +101,24 @@ body{font-size: 16px; color: #34495E; font-family: "Source Sans Pro","Helvetica
|
||||
/* -------- 自适应 --------- */
|
||||
/* 媒体查询 */
|
||||
@media screen and (max-width: 800px) {
|
||||
|
||||
.s-title{padding: 0 16px;}
|
||||
.s-width{width: 100%;}
|
||||
|
||||
.logo-box,.copyright {display: none;}
|
||||
.main-box{ height: auto;}
|
||||
.content-box{ padding: 2em 1em;}
|
||||
.content-box h1{font-size: 50px;}
|
||||
|
||||
.feature-z{padding: 0em;}
|
||||
.feature{min-width: 100%;}
|
||||
|
||||
.com-box-f{padding: 0em;}
|
||||
.com-box a{min-width: 90%;}
|
||||
|
||||
.footer-r-b{display: block;}
|
||||
.ss-box{display: block; width: 90%; margin: 0px; padding-left: 1.5em;}
|
||||
|
||||
/* .s-header{position: static;} */
|
||||
footer{position: static; line-height: 40px;}
|
||||
}
|
||||
@@ -118,4 +133,8 @@ body{font-size: 16px; color: #34495E; font-family: "Source Sans Pro","Helvetica
|
||||
0%{background-position: 0% 50%;}
|
||||
50%{background-position: 100% 50%;}
|
||||
100%{background-position: 0% 50%;}
|
||||
} */
|
||||
} */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ------------ 使用公司 ------------- -->
|
||||
<div>
|
||||
<div class="com-box-f s-width">
|
||||
@@ -188,6 +189,12 @@
|
||||
<a href="https://ms.airsr.com/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/com/tianquhangkong.png">
|
||||
</a>
|
||||
<a href="###">
|
||||
<img src="https://oss.dev33.cn/sa-token/com/huohaoduo.png">
|
||||
</a>
|
||||
<a href="http://www.jmwl51.com/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/com/jimeng.png">
|
||||
</a>
|
||||
</div>
|
||||
<div style="height: 10px; clear: both;"></div>
|
||||
<p style="color: #666;">
|
||||
@@ -208,25 +215,37 @@
|
||||
<h2 class="s-title">友情链接</h2>
|
||||
<div class="com-box com-box-you">
|
||||
<a href="https://gitee.com/dromara/soul" target="_blank">
|
||||
<img src="https://dromara.org/img/logo/soul.png">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/soul.png" msg="JAVA语言中可扩展,高性能,响应式的 API 网关">
|
||||
</a>
|
||||
<a href="https://yomahub.com/tlog/" target="_blank">
|
||||
<img src="https://gitee.com/dromara/TLog/raw/master/static/img/logo.png">
|
||||
<a href="https://gitee.com/dromara/TLog" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/tlog2.png" msg="一个轻量级的分布式日志标记追踪神器,10分钟即可接入,自动对日志打标签完成微服务的链路追踪">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/liteFlow" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/liteflow.png" msg="轻量,快速,稳定,可编排的组件式流程引擎">
|
||||
</a>
|
||||
<a href="https://dromara.org/zh/projects/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/dromara.png">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/dromara.png" msg="让每一位开源爱好者,体会到开源的快乐。">
|
||||
</a>
|
||||
<a href="https://okhttps.ejlchina.com/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/okhttps.png">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/okhttps.png" msg="如艺术一般优雅,像 1、2、3 一样简单,前后端通用,轻量却强大的 HTTP 客户端(同时支持 WebSocket 以及 Stomp 协议)">
|
||||
</a>
|
||||
<a href="https://xiaonuo.vip/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/xiaonuo.png">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/xiaonuo.png" msg="通用型后台权限管理框架,紧随潮流、开箱即用, 同时拥有Vue、Layui、SpringCloud三个版本">
|
||||
</a>
|
||||
<a href="https://cubic.jiagoujishu.com/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/cubic.png">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/cubic.png" msg="一站式问题定位平台,以agent的方式无侵入接入应用,完整集成arthas功能模块,致力于应用级监控,帮助开发人员快速定位问题">
|
||||
</a>
|
||||
<a href="http://www.pearadmin.com/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/pear-admin.png">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/pear-admin.png" msg="致 力 于 让 Web 开 发 变 得 简 单 优 雅">
|
||||
</a>
|
||||
<a href="https://maxkey.top/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/maxkey.png" msg="业界领先的身份管理和认证产品">
|
||||
</a>
|
||||
<a href="http://forest.dtflyx.com/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/forest-logo.png" msg="Forest能够帮助您使用更简单的方式编写Java的HTTP客户端">
|
||||
</a>
|
||||
<a href="https://jpom.io/" target="_blank">
|
||||
<img src="https://oss.dev33.cn/sa-token/link/jpom.png" msg="一款简而轻的低侵入式在线构建、自动部署、日常运维、项目监控软件">
|
||||
</a>
|
||||
</div>
|
||||
<div style="height: 10px; clear: both;"></div>
|
||||
@@ -239,11 +258,11 @@
|
||||
<div id="s-footer" class="mao-link"></div>
|
||||
<div class="footer-r-b s-width">
|
||||
<div class="ss-box">
|
||||
<h3>友情链接</h3>
|
||||
<h3>特别鸣谢</h3>
|
||||
<ul class="list-unstyle">
|
||||
<li><a href="https://dromara.org/zh/projects/" target="_blank">Dromara社区</a></li>
|
||||
<li><a href="https://docsify.js.org/#/zh-cn/" target="_blank">docsify</a></li>
|
||||
<li><a href="https://juejin.cn/" target="_blank">掘金 · 技术社区</a></li>
|
||||
<li><a href="http://yanzhi21.com" target="_blank">颜值排行榜</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ss-box">
|
||||
@@ -251,7 +270,7 @@
|
||||
<ul class="list-unstyle">
|
||||
<li><a href="https://www.aliyun.com/" target="_blank">阿里云</a></li>
|
||||
<li><a href="https://cloud.tencent.com/" target="_blank">腾讯云</a></li>
|
||||
<li><a href="http://yanzhi21.com" target="_blank">颜值排行榜</a></li>
|
||||
<li><a href="https://juejin.cn/" target="_blank">掘金 · 技术社区</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ss-box">
|
||||
@@ -317,7 +336,24 @@
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
<!-- 悬浮效果 -->
|
||||
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
|
||||
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
|
||||
<script type="text/javascript">
|
||||
// 鼠标悬浮在友情链接时,提示信息
|
||||
$(".com-box-you a img").hover(function(){
|
||||
var msg = $(this).attr("msg") ;
|
||||
if(msg) {
|
||||
window.msgLayer = layer.tips(msg, $(this), {tips: 1, time: 0});
|
||||
}
|
||||
},function(){
|
||||
var index = window.msgLayer;
|
||||
setTimeout(function() {
|
||||
layer.close(index);
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-parent</artifactId>
|
||||
<version>1.16.0</version>
|
||||
<version>1.16.0.RELEASE</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user