临时认证模块新增 deleteToken 方法用于回收 Token

This commit is contained in:
click33
2021-09-30 02:38:15 +08:00
parent b7dba13cab
commit ba5784abec
15 changed files with 91 additions and 31 deletions

View File

@@ -74,7 +74,7 @@ public class SaTokenConfig implements Serializable {
/**
* jwt秘钥 (只有集成 sa-token-temp-jwt 模块时此参数才会生效)
*/
private String jwtSecretKey;
private String jwtSecretkey;
/**
* Id-Token的有效期 (单位: 秒)
@@ -391,16 +391,16 @@ public class SaTokenConfig implements Serializable {
/**
* @return jwt秘钥 (只有集成 sa-token-temp-jwt 模块时此参数才会生效)
*/
public String getJwtSecretKey() {
return jwtSecretKey;
public String getJwtSecretkey() {
return jwtSecretkey;
}
/**
* @param jwtSecretKey jwt秘钥 (只有集成 sa-token-temp-jwt 模块时此参数才会生效)
* @param jwtSecretkey jwt秘钥 (只有集成 sa-token-temp-jwt 模块时此参数才会生效)
* @return 对象自身
*/
public SaTokenConfig setJwtSecretKey(String jwtSecretKey) {
this.jwtSecretKey = jwtSecretKey;
public SaTokenConfig setJwtSecretkey(String jwtSecretkey) {
this.jwtSecretkey = jwtSecretkey;
return this;
}
@@ -476,10 +476,11 @@ public class SaTokenConfig implements Serializable {
+ ", tokenStyle=" + tokenStyle
+ ", dataRefreshPeriod=" + dataRefreshPeriod + ", tokenSessionCheckLogin=" + tokenSessionCheckLogin
+ ", autoRenew=" + autoRenew + ", cookieDomain=" + cookieDomain + ", tokenPrefix=" + tokenPrefix
+ ", isPrint=" + isPrint + ", isLog=" + isLog + ", jwtSecretKey=" + jwtSecretKey + ", idTokenTimeout="
+ ", isPrint=" + isPrint + ", isLog=" + isLog + ", jwtSecretkey=" + jwtSecretkey + ", idTokenTimeout="
+ idTokenTimeout + ", basic=" + basic + ", currDomain=" + currDomain + ", sso=" + sso + "]";
}
/**
* <h1> 本函数设计已过时,未来版本可能移除此函数,请及时更换为 setIsConcurrent() ,使用方式保持不变 </h1>
* @param allowConcurrentLogin see note
@@ -501,5 +502,20 @@ public class SaTokenConfig implements Serializable {
return this;
}
/**
* @return <h1> 本函数设计已过时,未来版本可能移除此函数,请及时更换为 getJwtSecretkey() ,使用方式保持不变 </h1>
*/
public String getJwtSecretKey() {
return jwtSecretkey;
}
/**
* @param <h1> 本函数设计已过时,未来版本可能移除此函数,请及时更换为 setJwtSecretkey() ,使用方式保持不变 </h1>
* @return 对象自身
*/
public SaTokenConfig setJwtSecretKey(String jwtSecretKey) {
this.jwtSecretkey = jwtSecretKey;
return this;
}
}

View File

@@ -10,7 +10,7 @@ import java.util.Properties;
/**
* Sa-Token配置文件的构建工厂类
* <p>
* 只有在非IOC环境下才会用到此类
* 用于手动读取配置文件初始化 SaTokenConfig 对象,只有在非IOC环境下才会用到此类
*
* @author kong
*

View File

@@ -6,7 +6,13 @@ import cn.dev33.satoken.context.model.SaResponse;
import cn.dev33.satoken.exception.SaTokenException;
/**
* Sa-Token 上下文处理器 [默认实现类]
* Sa-Token 上下文处理器 [默认实现类]
*
* <p>
* 一般情况下框架会为你自动注入合适的上下文处理器,如果代码断点走到了此默认实现类,
* 说明你引入的依赖有问题或者错误的调用了Sa-Token的API 请在[在线开发文档 > 附录 > 常见问题排查] 中按照提示进行排查
* </p>
*
* @author kong
*
*/

View File

@@ -6,6 +6,12 @@ import cn.dev33.satoken.context.model.SaStorage;
/**
* Sa-Token 上下文处理器 [ThreadLocal版本]
*
* <p>
* 使用 [ThreadLocal版本] 上下文处理器需要在全局过滤器或者拦截器内率先调用
* SaTokenContextForThreadLocalStorage.setBox(req,res, sto) 初始化上下文
* </p>
*
* @author kong
*
*/

View File

@@ -7,6 +7,7 @@ import cn.dev33.satoken.exception.SaTokenException;
/**
* Sa-Token 上下文处理器 [ThreadLocal版本] ---- 对象存储器
*
* @author kong
*
*/

View File

@@ -176,7 +176,7 @@ public class SaTokenDaoDefaultImpl implements SaTokenDao {
/**
* 是否继续执行数据清理的线程标记
*/
public boolean refreshFlag;
public volatile boolean refreshFlag;
/**
@@ -224,7 +224,7 @@ public class SaTokenDaoDefaultImpl implements SaTokenDao {
}
}
});
refreshThread.start();
this.refreshThread.start();
}
/**

View File

@@ -1,7 +1,7 @@
package cn.dev33.satoken.exception;
/**
* 一个异常:代表停止路由匹配
* 一个异常:代表停止路由匹配进入Controller
*
* @author kong
*/

View File

@@ -147,14 +147,14 @@ public class SaIdTemplate {
* @return Token
*/
public String createToken() {
return SaFoxUtil.getRandomString(60);
return SaFoxUtil.getRandomString(64);
}
// -------------------- 拼接key
/**
* 拼接keyId-Token的存储key
* 拼接keyId-Token 的存储 key
* @return key
*/
public String splicingTokenSaveKey() {
@@ -162,7 +162,7 @@ public class SaIdTemplate {
}
/**
* 拼接keyId-Token的存储key
* 拼接key次级 Id-Token 的存储 key
* @return key
*/
public String splicingPastTokenSaveKey() {

View File

@@ -4,7 +4,19 @@ import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.strategy.SaStrategy;
/**
* 自定义Session工具类
* 自定义 Session 工具类
*
* <p>样例:
* <pre>
* // 在一处代码写入数据
* SaSession session = SaSessionCustomUtil.getSessionById("role-" + 1001);
* session.set("count", 1);
*
* // 在另一处代码获取数据
* SaSession session = SaSessionCustomUtil.getSessionById("role-" + 1001);
* int count = session.getInt("count");
* System.out.println("count=" + count);
* </pre>
*
* @author kong
*
@@ -12,12 +24,12 @@ import cn.dev33.satoken.strategy.SaStrategy;
public class SaSessionCustomUtil {
/**
* 添加上指定前缀防止恶意伪造Session
* 添加上指定前缀防止恶意伪造Session
*/
public static String sessionKey = "custom";
/**
* 拼接Key: 自定义Session的Id
* 拼接Key: 自定义Session的Id
*
* @param sessionId 会话id
* @return sessionId

View File

@@ -3,7 +3,7 @@ package cn.dev33.satoken.session;
import java.io.Serializable;
/**
* Token签名 Model
* Token 签名 Model
*
* 挂在到SaSession上的token签名
*
@@ -43,7 +43,7 @@ public class TokenSign implements Serializable {
}
/**
* @return token value
* @return token
*/
public String getValue() {
return value;

View File

@@ -12,7 +12,6 @@ import cn.dev33.satoken.util.SaTokenConsts;
*/
public class SaLoginModel {
/**
* 此次登录的客户端设备标识
*/

View File

@@ -61,6 +61,15 @@ public interface SaTempInterface {
String key = splicingKeyTempToken(token);
return SaManager.getSaTokenDao().getObjectTimeout(key);
}
/**
* 删除一个token
* @param token 指定token
*/
public default void deleteToken(String token) {
String key = splicingKeyTempToken(token);
SaManager.getSaTokenDao().deleteObject(key);
}
/**
* 获取映射关系的持久化key
@@ -74,7 +83,7 @@ public interface SaTempInterface {
/**
* @return jwt秘钥 (只有集成 sa-token-temp-jwt 模块时此参数才会生效)
*/
public default String getJwtSecretKey() {
public default String getJwtSecretkey() {
return null;
}