mirror of
https://gitee.com/dromara/sa-token.git
synced 2024-12-02 03:47:50 +08:00
修复 sa-token-sso 部分问题
This commit is contained in:
parent
8f467bbc9c
commit
35cb81085c
@ -34,7 +34,7 @@ public class H5Controller implements Render {
|
|||||||
// 根据ticket进行登录
|
// 根据ticket进行登录
|
||||||
@Mapping("/sso/doLoginByTicket")
|
@Mapping("/sso/doLoginByTicket")
|
||||||
public SaResult doLoginByTicket(String ticket) {
|
public SaResult doLoginByTicket(String ticket) {
|
||||||
Object loginId = SaSsoClientProcessor.instance.checkTicketByMode2Or3(ticket, "/sso/doLoginByTicket");
|
Object loginId = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
|
||||||
if(loginId != null) {
|
if(loginId != null) {
|
||||||
StpUtil.login(loginId);
|
StpUtil.login(loginId);
|
||||||
return SaResult.data(StpUtil.getTokenValue());
|
return SaResult.data(StpUtil.getTokenValue());
|
||||||
|
@ -33,7 +33,7 @@ public class H5Controller {
|
|||||||
// 根据ticket进行登录
|
// 根据ticket进行登录
|
||||||
@RequestMapping("/sso/doLoginByTicket")
|
@RequestMapping("/sso/doLoginByTicket")
|
||||||
public SaResult doLoginByTicket(String ticket) {
|
public SaResult doLoginByTicket(String ticket) {
|
||||||
Object loginId = SaSsoClientProcessor.instance.checkTicketByMode2Or3(ticket, "/sso/doLoginByTicket");
|
Object loginId = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
|
||||||
if(loginId != null) {
|
if(loginId != null) {
|
||||||
StpUtil.login(loginId);
|
StpUtil.login(loginId);
|
||||||
return SaResult.data(StpUtil.getTokenValue());
|
return SaResult.data(StpUtil.getTokenValue());
|
||||||
|
@ -165,9 +165,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<script src="./static/docsify-plugin.js?v=6"></script>
|
<script src="./static/docsify-plugin.js?v=7"></script>
|
||||||
<script src="./static/is-star-plugin.js?v=6"></script>
|
<script src="./static/is-star-plugin.js?v=7"></script>
|
||||||
<script src="./static/is-fill-in-wj-plugin.js?v=6"></script>
|
<script src="./static/is-fill-in-wj-plugin.js?v=7"></script>
|
||||||
<script>
|
<script>
|
||||||
var saTokenTopVersion = '1.38.0'; // Sa-Token最新版本
|
var saTokenTopVersion = '1.38.0'; // Sa-Token最新版本
|
||||||
var name = '<img style="width: 60px; height: 60px; vertical-align: middle;" src="logo.png" alt="logo" /> ';
|
var name = '<img style="width: 60px; height: 60px; vertical-align: middle;" src="logo.png" alt="logo" /> ';
|
||||||
|
@ -30,7 +30,7 @@ public class H5Controller {
|
|||||||
// 根据ticket进行登录
|
// 根据ticket进行登录
|
||||||
@RequestMapping("/sso/doLoginByTicket")
|
@RequestMapping("/sso/doLoginByTicket")
|
||||||
public SaResult doLoginByTicket(String ticket) {
|
public SaResult doLoginByTicket(String ticket) {
|
||||||
Object loginId = SaSsoClientProcessor.instance.checkTicketByMode2Or3(ticket, "/sso/doLoginByTicket");
|
Object loginId = SaSsoClientProcessor.instance.checkTicket(ticket, "/sso/doLoginByTicket");
|
||||||
if(loginId != null) {
|
if(loginId != null) {
|
||||||
StpUtil.login(loginId);
|
StpUtil.login(loginId);
|
||||||
return SaResult.data(StpUtil.getTokenValue());
|
return SaResult.data(StpUtil.getTokenValue());
|
||||||
|
@ -123,7 +123,7 @@ public class SaSsoClientProcessor {
|
|||||||
return res.redirect(serverAuthUrl);
|
return res.redirect(serverAuthUrl);
|
||||||
} else {
|
} else {
|
||||||
// 1、校验ticket,获取 loginId
|
// 1、校验ticket,获取 loginId
|
||||||
SaCheckTicketResult ctr = checkTicketByMode2Or3(ticket, apiName.ssoLogin);
|
SaCheckTicketResult ctr = checkTicket(ticket, apiName.ssoLogin);
|
||||||
|
|
||||||
// 2、如果开发者自定义了ticket结果值处理函数,则使用自定义的函数
|
// 2、如果开发者自定义了ticket结果值处理函数,则使用自定义的函数
|
||||||
if(cfg.ticketResultHandle != null) {
|
if(cfg.ticketResultHandle != null) {
|
||||||
@ -193,7 +193,7 @@ public class SaSsoClientProcessor {
|
|||||||
SaResult result = ssoClientTemplate.request(url);
|
SaResult result = ssoClientTemplate.request(url);
|
||||||
|
|
||||||
// 校验响应状态码
|
// 校验响应状态码
|
||||||
if(SaResult.CODE_SUCCESS == result.getCode()) {
|
if(result.getCode() != null && SaResult.CODE_SUCCESS == result.getCode()) {
|
||||||
// 极端场景下,sso-server 中心的单点注销可能并不会通知到此 client 端,所以这里需要再补一刀
|
// 极端场景下,sso-server 中心的单点注销可能并不会通知到此 client 端,所以这里需要再补一刀
|
||||||
if(stpLogic.isLogin()) {
|
if(stpLogic.isLogin()) {
|
||||||
stpLogic.logout();
|
stpLogic.logout();
|
||||||
@ -240,12 +240,12 @@ public class SaSsoClientProcessor {
|
|||||||
// 工具方法
|
// 工具方法
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 封装:校验ticket,取出loginId,如果 ticket 无效则抛出异常
|
* 封装:校验ticket,取出loginId,如果 ticket 无效则抛出异常 (适用于模式二或模式三)
|
||||||
* @param ticket ticket码
|
* @param ticket ticket码
|
||||||
* @param currUri 当前路由的uri,用于计算单点注销回调地址
|
* @param currUri 当前路由的uri,用于计算单点注销回调地址 (如果是使用模式二,可以填写null)
|
||||||
* @return loginId
|
* @return loginId
|
||||||
*/
|
*/
|
||||||
public SaCheckTicketResult checkTicketByMode2Or3(String ticket, String currUri) {
|
public SaCheckTicketResult checkTicket(String ticket, String currUri) {
|
||||||
SaSsoClientConfig cfg = ssoClientTemplate.getClientConfig();
|
SaSsoClientConfig cfg = ssoClientTemplate.getClientConfig();
|
||||||
ApiName apiName = ssoClientTemplate.apiName;
|
ApiName apiName = ssoClientTemplate.apiName;
|
||||||
ParamName paramName = ssoClientTemplate.paramName;
|
ParamName paramName = ssoClientTemplate.paramName;
|
||||||
|
@ -220,8 +220,8 @@ public class SaSsoServerProcessor {
|
|||||||
return ssoSignoutByUserVisit();
|
return ssoSignoutByUserVisit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSO-Server端:单点注销 [Client调用式] (带loginId参数 & isHttp=true)
|
// SSO-Server端:单点注销 [Client调用式] (带loginId参数)
|
||||||
if(cfg.getIsHttp() && cfg.getIsSlo() && req.hasParam(paramName.loginId)) {
|
if(cfg.getIsSlo() && req.hasParam(paramName.loginId)) {
|
||||||
return ssoSignoutByClientHttp();
|
return ssoSignoutByClientHttp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user