From 97831145f8ba902d5d4e2e4e75033d3ba64f0b89 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 5 Nov 2025 18:46:54 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20Api=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=BC=BA=E5=88=B6=E9=9C=80=E8=A6=81=E6=B7=BB=E5=8A=A0=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1547962277134336]Api接口强制需要添加权限控制 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1547962277134336 --- .../framework/auth/label/NoAuth.java | 25 +++++++++++++++++++ .../restful/core/ApiValidateAndHelpBase.java | 5 ++++ 2 files changed, 30 insertions(+) create mode 100644 src/main/java/neatlogic/framework/auth/label/NoAuth.java diff --git a/src/main/java/neatlogic/framework/auth/label/NoAuth.java b/src/main/java/neatlogic/framework/auth/label/NoAuth.java new file mode 100644 index 000000000..fcc9ee616 --- /dev/null +++ b/src/main/java/neatlogic/framework/auth/label/NoAuth.java @@ -0,0 +1,25 @@ +package neatlogic.framework.auth.label; + +import neatlogic.framework.auth.core.AuthBase; + +public class NoAuth extends AuthBase { + @Override + public String getAuthDisplayName() { + return "无权限"; + } + + @Override + public String getAuthIntroduction() { + return "无权限"; + } + + @Override + public String getAuthGroup() { + return "framework"; + } + + @Override + public Integer getSort() { + return Integer.MAX_VALUE; + } +} diff --git a/src/main/java/neatlogic/framework/restful/core/ApiValidateAndHelpBase.java b/src/main/java/neatlogic/framework/restful/core/ApiValidateAndHelpBase.java index e5d53ee11..863e101cb 100644 --- a/src/main/java/neatlogic/framework/restful/core/ApiValidateAndHelpBase.java +++ b/src/main/java/neatlogic/framework/restful/core/ApiValidateAndHelpBase.java @@ -25,6 +25,7 @@ import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.auth.core.AuthActionChecker; import neatlogic.framework.auth.core.AuthBase; import neatlogic.framework.auth.core.AuthFactory; +import neatlogic.framework.auth.label.NoAuth; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.common.constvalue.IEnum; import neatlogic.framework.common.constvalue.systemuser.SystemUserFactory; @@ -244,6 +245,10 @@ public class ApiValidateAndHelpBase { private boolean isApiAuth(Class apiClass, List authNameList, AuthAction[] actions) { boolean isAuth = false; for (AuthAction action : actions) { + if (action.action() == NoAuth.class) { + isAuth = true; + break; + } if (StringUtils.isNotBlank(action.action().getSimpleName())) { String actionName = action.action().getSimpleName(); // 判断用户角色是否拥有接口权限 -- Gitee