mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-04-30 04:45:51 +08:00
SaSsoConfig 新增配置 isCheckSign(是否校验参数签名),方便本地开发时的调试。
This commit is contained in:
parent
c8a5b922a2
commit
2c87e47b2b
@ -36,14 +36,14 @@ public class SaSsoConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6541180061782004705L;
|
||||
|
||||
|
||||
|
||||
// ----------------- Server端相关配置
|
||||
|
||||
/**
|
||||
* 指定当前系统集成 SSO 时使用的模式(约定型配置项,不对代码逻辑产生任何影响)
|
||||
*/
|
||||
public String mode = "";
|
||||
|
||||
|
||||
/**
|
||||
* Ticket有效期 (单位: 秒)
|
||||
*/
|
||||
@ -62,9 +62,9 @@ public class SaSsoConfig implements Serializable {
|
||||
/**
|
||||
* 是否打开模式三(此值为 true 时将使用 http 请求:校验ticket值、单点注销、获取userinfo)
|
||||
*/
|
||||
public Boolean isHttp = false;
|
||||
public Boolean isHttp = false;
|
||||
|
||||
|
||||
|
||||
// ----------------- Client端相关配置
|
||||
|
||||
// /**
|
||||
@ -127,6 +127,11 @@ public class SaSsoConfig implements Serializable {
|
||||
*/
|
||||
public String serverUrl;
|
||||
|
||||
/**
|
||||
* 是否校验参数签名(方便本地调试用的一个配置项,生产环境请务必为true)
|
||||
*/
|
||||
public Boolean isCheckSign = true;
|
||||
|
||||
|
||||
/**
|
||||
* 获取 指定当前系统集成 SSO 时使用的模式(约定型配置项,不对代码逻辑产生任何影响)
|
||||
@ -337,6 +342,25 @@ public class SaSsoConfig implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 是否校验参数签名(方便本地调试用的一个配置项,生产环境请务必为true)
|
||||
*
|
||||
* @return isCheckSign 是否校验参数签名(方便本地调试用的一个配置项,生产环境请务必为true)
|
||||
*/
|
||||
public Boolean getIsCheckSign() {
|
||||
return this.isCheckSign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 是否校验参数签名(方便本地调试用的一个配置项,生产环境请务必为true)
|
||||
*
|
||||
* @param isCheckSign 是否校验参数签名(方便本地调试用的一个配置项,生产环境请务必为true)
|
||||
*/
|
||||
public SaSsoConfig setIsCheckSign(Boolean isCheckSign) {
|
||||
this.isCheckSign = isCheckSign;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SaSsoConfig ["
|
||||
@ -353,6 +377,7 @@ public class SaSsoConfig implements Serializable {
|
||||
+ ", sloUrl=" + sloUrl
|
||||
+ ", ssoLogoutCall=" + ssoLogoutCall
|
||||
+ ", serverUrl=" + serverUrl
|
||||
+ ", isCheckSign=" + isCheckSign
|
||||
+ "]";
|
||||
}
|
||||
|
||||
@ -412,7 +437,7 @@ public class SaSsoConfig implements Serializable {
|
||||
* SSO-Server端:未登录时返回的View
|
||||
*/
|
||||
public Supplier<Object> notLoginView = () -> {
|
||||
return "当前会话在SSO-Server认证中心尚未登录";
|
||||
return "当前会话在SSO-Server认证中心尚未登录(当前未配置登录视图)";
|
||||
};
|
||||
|
||||
/**
|
||||
@ -438,7 +463,7 @@ public class SaSsoConfig implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* @param notLoginView SSO-Server端:未登录时返回的View
|
||||
* @param notLoginView SSO-Server端:未登录时返回的View
|
||||
* @return 对象自身
|
||||
*/
|
||||
public SaSsoConfig setNotLoginView(Supplier<Object> notLoginView) {
|
||||
|
@ -132,7 +132,7 @@ public class SaSsoProcessor {
|
||||
*/
|
||||
public Object ssoCheckTicket() {
|
||||
ParamName paramName = ssoTemplate.paramName;
|
||||
|
||||
|
||||
// 1、获取参数
|
||||
SaRequest req = SaHolder.getRequest();
|
||||
String client = req.getParam(paramName.client);
|
||||
@ -140,8 +140,10 @@ public class SaSsoProcessor {
|
||||
String sloCallback = req.getParam(paramName.ssoLogoutCall);
|
||||
|
||||
// 2、校验签名
|
||||
ssoTemplate.getSignTemplate().checkRequest(req,
|
||||
paramName.client, paramName.ticket, paramName.ssoLogoutCall);
|
||||
if(ssoTemplate.getSsoConfig().getIsCheckSign()) {
|
||||
ssoTemplate.getSignTemplate().checkRequest(req,
|
||||
paramName.client, paramName.ticket, paramName.ssoLogoutCall);
|
||||
}
|
||||
|
||||
// 3、校验ticket,获取 loginId
|
||||
Object loginId = ssoTemplate.checkTicket(ticket, client);
|
||||
@ -210,8 +212,10 @@ public class SaSsoProcessor {
|
||||
SaRequest req = SaHolder.getRequest();
|
||||
String loginId = req.getParam(paramName.loginId);
|
||||
|
||||
// step.1 校验签名
|
||||
ssoTemplate.getSignTemplate().checkRequest(req, paramName.loginId);
|
||||
// step.1 校验签名
|
||||
if(ssoTemplate.getSsoConfig().getIsCheckSign()) {
|
||||
ssoTemplate.getSignTemplate().checkRequest(req, paramName.loginId);
|
||||
}
|
||||
|
||||
// step.2 单点注销
|
||||
ssoTemplate.ssoLogout(loginId);
|
||||
@ -392,7 +396,9 @@ public class SaSsoProcessor {
|
||||
String loginId = req.getParamNotNull(paramName.loginId);
|
||||
|
||||
// 校验参数签名
|
||||
ssoTemplate.getSignTemplate().checkRequest(req, paramName.loginId);
|
||||
if(ssoTemplate.getSsoConfig().getIsCheckSign()) {
|
||||
ssoTemplate.getSignTemplate().checkRequest(req, paramName.loginId);
|
||||
}
|
||||
|
||||
// 注销当前应用端会话
|
||||
stpLogic.logout(loginId);
|
||||
|
Loading…
Reference in New Issue
Block a user