修复 sa-token-sso 部分问题

This commit is contained in:
click33 2024-05-12 12:40:05 +08:00
parent 8f467bbc9c
commit 35cb81085c
6 changed files with 13 additions and 13 deletions

View File

@ -34,7 +34,7 @@ public class H5Controller implements Render {
// 根据ticket进行登录
@Mapping("/sso/doLoginByTicket")
public SaResult doLoginByTicket(String ticket) {
Object loginId = SaSsoClientProcessor.instance.checkTicketByMode2Or3(ticket, "/sso/doLoginByTicket");
Object loginId = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
if(loginId != null) {
StpUtil.login(loginId);
return SaResult.data(StpUtil.getTokenValue());

View File

@ -33,7 +33,7 @@ public class H5Controller {
// 根据ticket进行登录
@RequestMapping("/sso/doLoginByTicket")
public SaResult doLoginByTicket(String ticket) {
Object loginId = SaSsoClientProcessor.instance.checkTicketByMode2Or3(ticket, "/sso/doLoginByTicket");
Object loginId = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
if(loginId != null) {
StpUtil.login(loginId);
return SaResult.data(StpUtil.getTokenValue());

View File

@ -165,9 +165,9 @@
</script>
<!-- -->
<script src="./static/docsify-plugin.js?v=6"></script>
<script src="./static/is-star-plugin.js?v=6"></script>
<script src="./static/is-fill-in-wj-plugin.js?v=6"></script>
<script src="./static/docsify-plugin.js?v=7"></script>
<script src="./static/is-star-plugin.js?v=7"></script>
<script src="./static/is-fill-in-wj-plugin.js?v=7"></script>
<script>
var saTokenTopVersion = '1.38.0'; // Sa-Token最新版本
var name = '<img style="width: 60px; height: 60px; vertical-align: middle;" src="logo.png" alt="logo" /> ';

View File

@ -30,7 +30,7 @@ public class H5Controller {
// 根据ticket进行登录
@RequestMapping("/sso/doLoginByTicket")
public SaResult doLoginByTicket(String ticket) {
Object loginId = SaSsoClientProcessor.instance.checkTicketByMode2Or3(ticket, "/sso/doLoginByTicket");
Object loginId = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
if(loginId != null) {
StpUtil.login(loginId);
return SaResult.data(StpUtil.getTokenValue());

View File

@ -123,7 +123,7 @@ public class SaSsoClientProcessor {
return res.redirect(serverAuthUrl);
} else {
// 1校验ticket获取 loginId
SaCheckTicketResult ctr = checkTicketByMode2Or3(ticket, apiName.ssoLogin);
SaCheckTicketResult ctr = checkTicket(ticket, apiName.ssoLogin);
// 2如果开发者自定义了ticket结果值处理函数则使用自定义的函数
if(cfg.ticketResultHandle != null) {
@ -193,7 +193,7 @@ public class SaSsoClientProcessor {
SaResult result = ssoClientTemplate.request(url);
// 校验响应状态码
if(SaResult.CODE_SUCCESS == result.getCode()) {
if(result.getCode() != null && SaResult.CODE_SUCCESS == result.getCode()) {
// 极端场景下sso-server 中心的单点注销可能并不会通知到此 client 所以这里需要再补一刀
if(stpLogic.isLogin()) {
stpLogic.logout();
@ -240,12 +240,12 @@ public class SaSsoClientProcessor {
// 工具方法
/**
* 封装校验ticket取出loginId如果 ticket 无效则抛出异常
* 封装校验ticket取出loginId如果 ticket 无效则抛出异常 适用于模式二或模式三
* @param ticket ticket码
* @param currUri 当前路由的uri用于计算单点注销回调地址
* @param currUri 当前路由的uri用于计算单点注销回调地址 如果是使用模式二可以填写null
* @return loginId
*/
public SaCheckTicketResult checkTicketByMode2Or3(String ticket, String currUri) {
public SaCheckTicketResult checkTicket(String ticket, String currUri) {
SaSsoClientConfig cfg = ssoClientTemplate.getClientConfig();
ApiName apiName = ssoClientTemplate.apiName;
ParamName paramName = ssoClientTemplate.paramName;

View File

@ -220,8 +220,8 @@ public class SaSsoServerProcessor {
return ssoSignoutByUserVisit();
}
// SSO-Server端单点注销 [Client调用式] (带loginId参数 & isHttp=true)
if(cfg.getIsHttp() && cfg.getIsSlo() && req.hasParam(paramName.loginId)) {
// SSO-Server端单点注销 [Client调用式] (带loginId参数)
if(cfg.getIsSlo() && req.hasParam(paramName.loginId)) {
return ssoSignoutByClientHttp();
}