为 jwt-mixin 模式适配 max-try-times 属性

This commit is contained in:
click33
2023-04-30 23:02:04 +08:00
parent a72ba8379b
commit 453030058f
5 changed files with 23 additions and 7 deletions

View File

@@ -42,7 +42,7 @@
</dependency>
<!-- Sa-Token 整合 Redis (使用jackson序列化方式) -->
<!-- <dependency>
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-dao-redis-jackson</artifactId>
<version>${sa-token.version}</version>
@@ -50,7 +50,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency> -->
</dependency>
<!-- @ConfigurationProperties -->
<dependency>

View File

@@ -234,6 +234,12 @@ public void setSaJwtTemplate() {
技术上来讲无法将其踢下线,所以此时顶人下线和踢人下线等 API 都属于不可用状态,所以此时 `is-concurrent` 配置项必须配置为 `true`。
##### 3、使用 jwt-mixin 模式后max-try-times 恒等于 -1。
为防止框架错误判断 token 唯一性,当使用 jwt-mixin 模式后,`max-try-times` 恒等于 -1。

View File

@@ -110,7 +110,7 @@ public class SaTokenConfigure {
---
### 所有可配置项
你不必立刻掌握整个表格,只需要在用到某个功能时再详细查阅它即可
**你不必立刻掌握整个表格,只需要在用到某个功能时再详细查阅它即可**
| 参数名称 | 类型 | 默认值 | 说明 |
| :-------- | :-------- | :-------- | :-------- |
@@ -120,6 +120,7 @@ public class SaTokenConfigure {
| isConcurrent | Boolean | true | 是否允许同一账号并发登录 (为 true 时允许一起登录,为 false 时新登录挤掉旧登录) |
| isShare | Boolean | true | 在多人登录同一账号时是否共用一个token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token |
| maxLoginCount | int | 12 | 同一账号最大登录数量,-1代表不限 (只有在 `isConcurrent=true`, `isShare=false` 时此配置才有效),[详解](/use/config?id=配置项详解maxlogincount) |
| maxTryTimes | int | 12 | 在每次创建 Token 时的最高循环次数,用于保证 Token 唯一性(-1=不循环重试,直接使用) |
| isReadBody | Boolean | true | 是否尝试从 请求体 里读取 Token |
| isReadHeader | Boolean | true | 是否尝试从 header 里读取 Token |
| isReadCookie | Boolean | true | 是否尝试从 cookie 里读取 Token此值为 false 后,`StpUtil.login(id)` 登录时也不会再往前端注入Cookie |

View File

@@ -212,7 +212,7 @@ public class StpLogicJwtForMixin extends StpLogic {
// ------------------- Bean对象代理 -------------------
/**
* 返回全局配置对象的isShare属性
* 返回全局配置对象的 isShare 属性
* @return /
*/
@Override
@@ -220,4 +220,13 @@ public class StpLogicJwtForMixin extends StpLogic {
return false;
}
/**
* 返回全局配置对象的 maxTryTimes 属性
* @return /
*/
@Override
public int getConfigOfMaxTryTimes() {
return -1;
}
}