From 000cdf5180a9b744d2b9ba8239bfbc029b893f80 Mon Sep 17 00:00:00 2001 From: lilong Date: Thu, 4 Jul 2024 17:14:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:(hotfix/REQ-20240704)=20=E9=89=B4=E6=9D=83?= =?UTF-8?q?=E5=92=8C=E6=9F=A5=E8=AF=A2=E8=8F=9C=E5=8D=95=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=94=A8=E6=88=B7=E6=B2=A1=E6=9C=89=E8=A7=92?= =?UTF-8?q?=E8=89=B2=EF=BC=8C=E5=88=99=E5=BF=AB=E9=80=9F=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tyr/client/model/req/IdentityAuthReq.java | 19 +++++++++++++++++++ .../service/impl/TyrSaasAuthServiceImpl.java | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/IdentityAuthReq.java b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/IdentityAuthReq.java index 099f3495..e9001694 100644 --- a/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/IdentityAuthReq.java +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/IdentityAuthReq.java @@ -4,6 +4,7 @@ import cn.axzo.framework.auth.domain.TerminalInfo; import cn.axzo.tyr.client.common.enums.WorkspaceJoinType; import cn.axzo.tyr.client.model.enums.FeatureType; import cn.axzo.tyr.client.model.enums.IdentityType; +import cn.axzo.tyr.client.model.res.IdentityAuthRes; import cn.hutool.core.collection.CollectionUtil; import lombok.AllArgsConstructor; import lombok.Builder; @@ -73,6 +74,24 @@ public class IdentityAuthReq { @Builder.Default private boolean useCache = true; + public IdentityAuthRes toEmpty() { + IdentityAuthRes result = new IdentityAuthRes(); + result.setIdentity(this.getIdentityId()); + result.setIdentityType(this.getIdentityType()); + result.setPersonId(this.getPersonId()); + + List permissions = this.getWorkspaceOusPairs().stream() + .map(workspaceOuPair -> IdentityAuthRes.WorkspacePermission.builder() + .workspaceId(workspaceOuPair.getWorkspaceId()) + .ouId(workspaceOuPair.getOuId()) + .build()) + .collect(Collectors.toList()); + result.setPermissions(permissions); + + return result; + } + + public void distinctOUWorkspacePair() { if (CollectionUtil.isEmpty(this.workspaceOusPairs)) { return; diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/TyrSaasAuthServiceImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/TyrSaasAuthServiceImpl.java index fccbda58..5a5822eb 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/TyrSaasAuthServiceImpl.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/TyrSaasAuthServiceImpl.java @@ -59,6 +59,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -318,6 +319,10 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService { //用户角色关系 List saasRoleUserRelations = listRoleUserRelations(identityAuthReq); + if (CollectionUtils.isEmpty(saasRoleUserRelations)) { + log.warn("no user role relations found"); + return identityAuthReq.toEmpty(); + } Set realWorkspaceId = saasRoleUserRelations.stream().map(SaasRoleUserRelation::getWorkspaceId).collect(Collectors.toSet()); //工作台对应产品 key = workspaceId