mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-02-27 16:50:24 +08:00
feat(sso): 单点注销消息推送时忽略掉发起调用的 client,减少不必要的调用
This commit is contained in:
@@ -61,12 +61,13 @@ public class SaSsoMessageSignoutHandle implements SaSsoMessageHandle {
|
||||
}
|
||||
|
||||
// 3、获取参数
|
||||
String client = message.getString(paramName.client);
|
||||
Object loginId = message.get(paramName.loginId);
|
||||
String deviceId = message.getString(paramName.deviceId);
|
||||
|
||||
// 4、单点注销
|
||||
SaLogoutParameter logoutParameter = ssoServerTemplate.getStpLogicOrGlobal().createSaLogoutParameter().setDeviceId(deviceId);
|
||||
ssoServerTemplate.ssoLogout(loginId, logoutParameter);
|
||||
ssoServerTemplate.ssoLogout(loginId, logoutParameter, client);
|
||||
|
||||
// 5、响应
|
||||
return SaResult.ok();
|
||||
|
||||
@@ -187,7 +187,7 @@ public class SaSsoServerProcessor {
|
||||
if(singleDeviceIdLogout) {
|
||||
logoutParameter.setDeviceId(stpLogic.getLoginDeviceId());
|
||||
}
|
||||
ssoServerTemplate.ssoLogout(loginId, logoutParameter);
|
||||
ssoServerTemplate.ssoLogout(loginId, logoutParameter, null);
|
||||
}
|
||||
|
||||
// 完成
|
||||
|
||||
@@ -573,7 +573,7 @@ public class SaSsoServerTemplate extends SaSsoTemplate {
|
||||
* @param loginId 指定账号
|
||||
*/
|
||||
public void ssoLogout(Object loginId) {
|
||||
ssoLogout(loginId, getStpLogicOrGlobal().createSaLogoutParameter());
|
||||
ssoLogout(loginId, getStpLogicOrGlobal().createSaLogoutParameter(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -581,11 +581,12 @@ public class SaSsoServerTemplate extends SaSsoTemplate {
|
||||
*
|
||||
* @param loginId 指定账号
|
||||
* @param logoutParameter 注销参数
|
||||
* @param ignoreClient 要被忽略掉的 client,填 null 代表不忽略
|
||||
*/
|
||||
public void ssoLogout(Object loginId, SaLogoutParameter logoutParameter) {
|
||||
public void ssoLogout(Object loginId, SaLogoutParameter logoutParameter, String ignoreClient) {
|
||||
|
||||
// 1、消息推送:单点注销
|
||||
pushToAllClientByLogoutCall(loginId, logoutParameter);
|
||||
pushToAllClientByLogoutCall(loginId, logoutParameter, ignoreClient);
|
||||
|
||||
// 2、SaSession 挂载的 Client 端注销会话
|
||||
SaSession session = getStpLogicOrGlobal().getSessionByLoginId(loginId, false);
|
||||
@@ -717,7 +718,7 @@ public class SaSsoServerTemplate extends SaSsoTemplate {
|
||||
public void pushToAllClient(SaSsoMessage message, String ignoreClient) {
|
||||
List<SaSsoClientModel> needPushClients = getNeedPushClients();
|
||||
for (SaSsoClientModel client : needPushClients) {
|
||||
if(ignoreClient != null && ignoreClient.equals(client.getClient())) {
|
||||
if(SaFoxUtil.isNotEmpty(ignoreClient) && ignoreClient.equals(client.getClient())) {
|
||||
continue;
|
||||
}
|
||||
strategy.asyncRun.run(() -> pushMessage(client, message));
|
||||
@@ -729,10 +730,14 @@ public class SaSsoServerTemplate extends SaSsoTemplate {
|
||||
*
|
||||
* @param loginId /
|
||||
* @param logoutParameter 注销参数
|
||||
* @param ignoreClient 要被忽略掉的 client,填 null 代表不忽略
|
||||
*/
|
||||
public void pushToAllClientByLogoutCall(Object loginId, SaLogoutParameter logoutParameter) {
|
||||
public void pushToAllClientByLogoutCall(Object loginId, SaLogoutParameter logoutParameter, String ignoreClient) {
|
||||
List<SaSsoClientModel> npClients = getNeedPushClients();
|
||||
for (SaSsoClientModel client : npClients) {
|
||||
if(SaFoxUtil.isNotEmpty(ignoreClient) && ignoreClient.equals(client.getClient())) {
|
||||
continue;
|
||||
}
|
||||
if(client.getIsSlo()) {
|
||||
strategy.asyncRun.run(() -> {
|
||||
pushToClientByLogoutCall(client, loginId, false, logoutParameter);
|
||||
|
||||
@@ -238,9 +238,10 @@ public class SaSsoServerUtil {
|
||||
*
|
||||
* @param loginId 指定账号
|
||||
* @param logoutParameter 注销参数
|
||||
* @param ignoreClient 要被忽略掉的 client,填 null 代表不忽略
|
||||
*/
|
||||
public static void ssoLogout(Object loginId, SaLogoutParameter logoutParameter) {
|
||||
SaSsoServerProcessor.instance.ssoServerTemplate.ssoLogout(loginId, logoutParameter);
|
||||
public static void ssoLogout(Object loginId, SaLogoutParameter logoutParameter, String ignoreClient) {
|
||||
SaSsoServerProcessor.instance.ssoServerTemplate.ssoLogout(loginId, logoutParameter, ignoreClient);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user