From 9b687ff6c9eb945f29c2728704841e9443a01108 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 16 Apr 2022 00:33:34 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E7=9A=84=20URL=EF=BC=8C=E6=9C=AA=E5=B8=A6?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E4=BC=9A=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tenant/core/security/TenantSecurityWebFilter.java | 6 +++++- .../system/controller/admin/tenant/TenantController.http | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java index 31cab144b3..9a047312c1 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java @@ -75,7 +75,7 @@ public class TenantSecurityWebFilter extends ApiRequestFilter { } } - //检查是否是忽略的 URL, 如果是则允许访问 + // 如果非允许忽略租户的 URL,则校验租户是否合法 if (!isIgnoreUrl(request)) { // 2. 如果请求未带租户的编号,不允许访问。 if (tenantId == null) { @@ -92,6 +92,10 @@ public class TenantSecurityWebFilter extends ApiRequestFilter { ServletUtils.writeJSON(response, result); return; } + } else { // 如果是允许忽略租户的 URL,若未传递租户编号,则默认忽略租户编号,避免报错 + if (tenantId == null) { + TenantContextHolder.setIgnore(true); + } } // 继续过滤 diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.http b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.http index ea3eb34579..a4d517385b 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.http +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.http @@ -1,3 +1,6 @@ +### 获取租户编号 /admin-api/system/get-id-by-name +GET {{baseUrl}}/system/tenant/get-id-by-name?name=芋道源码 + ### 创建租户 /admin-api/system/tenant/create POST {{baseUrl}}/system/tenant/create Content-Type: application/json