mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-05-14 12:52:08 +08:00
feat: 新增配置项 cookieAutoFillPrefix:cookie 模式是否自动填充 token 前缀
This commit is contained in:
@@ -153,6 +153,11 @@ public class SaTokenConfig implements Serializable {
|
||||
*/
|
||||
private String tokenPrefix;
|
||||
|
||||
/**
|
||||
* cookie 模式是否自动填充 token 前缀
|
||||
*/
|
||||
private Boolean cookieAutoFillPrefix = false;
|
||||
|
||||
/**
|
||||
* 是否在初始化配置时在控制台打印版本字符画
|
||||
*/
|
||||
@@ -517,7 +522,23 @@ public class SaTokenConfig implements Serializable {
|
||||
this.tokenPrefix = tokenPrefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return cookie 模式是否自动填充 token 前缀
|
||||
*/
|
||||
public Boolean getCookieAutoFillPrefix() {
|
||||
return cookieAutoFillPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cookieAutoFillPrefix cookie 模式是否自动填充 token 前缀
|
||||
* @return 对象自身
|
||||
*/
|
||||
public SaTokenConfig setCookieAutoFillPrefix(Boolean cookieAutoFillPrefix) {
|
||||
this.cookieAutoFillPrefix = cookieAutoFillPrefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 是否在初始化配置时在控制台打印版本字符画
|
||||
*/
|
||||
@@ -877,8 +898,9 @@ public class SaTokenConfig implements Serializable {
|
||||
+ ", tokenStyle=" + tokenStyle
|
||||
+ ", dataRefreshPeriod=" + dataRefreshPeriod
|
||||
+ ", tokenSessionCheckLogin=" + tokenSessionCheckLogin
|
||||
+ ", autoRenew=" + autoRenew
|
||||
+ ", autoRenew=" + autoRenew
|
||||
+ ", tokenPrefix=" + tokenPrefix
|
||||
+ ", cookieAutoFillPrefix=" + cookieAutoFillPrefix
|
||||
+ ", isPrint=" + isPrint
|
||||
+ ", isLog=" + isLog
|
||||
+ ", logLevel=" + logLevel
|
||||
|
||||
@@ -351,6 +351,9 @@ public class StpLogic {
|
||||
// 4. 最后尝试从 cookie 里读取
|
||||
if(SaFoxUtil.isEmpty(tokenValue) && config.getIsReadCookie()){
|
||||
tokenValue = request.getCookieValue(keyTokenName);
|
||||
if(SaFoxUtil.isNotEmpty(tokenValue) && config.getCookieAutoFillPrefix()) {
|
||||
tokenValue = config.getTokenPrefix() + SaTokenConsts.TOKEN_CONNECTOR_CHAT + tokenValue;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 至此,不管有没有读取到,都不再尝试了,直接返回
|
||||
|
||||
Reference in New Issue
Block a user