新增 autoRenewTimeout 配置项:是否在每次下发 ticket 时,自动续期 token 的有效期(根据全局 timeout 值)

This commit is contained in:
click33 2024-05-03 16:14:40 +08:00
parent 5a7463dc91
commit 64abd69715
3 changed files with 28 additions and 1 deletions

View File

@ -69,6 +69,11 @@ public class SaSsoServerConfig implements Serializable {
*/
public Boolean isHttp = false;
/**
* 是否在每次下发 ticket 自动续期 token 的有效期根据全局 timeout
*/
public Boolean autoRenewTimeout = false;
/**
* Access-Session 上记录 Client 信息的最高数量-1=无限超过此值将进行自动清退处理先进先出
*/
@ -180,6 +185,22 @@ public class SaSsoServerConfig implements Serializable {
return this;
}
/**
* @return 是否在每次下发 ticket 自动续期 token 的有效期根据全局 timeout
*/
public Boolean getAutoRenewTimeout() {
return autoRenewTimeout;
}
/**
* @param autoRenewTimeout 是否在每次下发 ticket 自动续期 token 的有效期根据全局 timeout
* @return 对象自身
*/
public SaSsoServerConfig setAutoRenewTimeout(Boolean autoRenewTimeout) {
this.autoRenewTimeout = autoRenewTimeout;
return this;
}
/**
* @return maxLoginClient Access-Session 上记录 Client 信息的最高数量-1=无限超过此值将进行自动清退处理先进先出
*/
@ -234,6 +255,7 @@ public class SaSsoServerConfig implements Serializable {
+ ", homeRoute=" + homeRoute
+ ", isSlo=" + isSlo
+ ", isHttp=" + isHttp
+ ", autoRenewTimeout=" + autoRenewTimeout
+ ", maxRegClient=" + maxRegClient
+ ", isCheckSign=" + isCheckSign
+ "]";

View File

@ -285,7 +285,7 @@ public class SaSsoClientProcessor {
// 取出 Session 剩余有效期
Long remainSessionTimeout = result.get(paramName.remainSessionTimeout, Long.class);
if(remainSessionTimeout == null) {
remainSessionTimeout = ssoClientTemplate.getStpLogic().getConfig().getTimeout();
remainSessionTimeout = ssoClientTemplate.getStpLogic().getConfigOrGlobal().getTimeout();
}
// 构建返回
return new CheckTicketResult(loginId, remainSessionTimeout);

View File

@ -139,6 +139,11 @@ public class SaSsoServerProcessor {
// 构建并跳转
String redirectUrl = ssoServerTemplate.buildRedirectUrl(stpLogic.getLoginId(), client, redirect);
// 构建成功说明 redirect 地址合法此时需要更新一下该账号的Session有效期
if(cfg.getAutoRenewTimeout()) {
stpLogic.renewTimeout(stpLogic.getConfigOrGlobal().getTimeout());
}
// 跳转
return res.redirect(redirectUrl);
}
}