From 81b72b5693759e3136f9310f9f412451ab992a05 Mon Sep 17 00:00:00 2001 From: jay <75509151@qq.com> Date: Wed, 26 Jul 2023 11:13:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20iot-openapi=20=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/satoken/config/SaTokenConfig.java | 17 ++++++++- iot-module/iot-openapi/pom.xml | 38 ------------------- .../controller/OpenBaseController.java | 1 - iot-starter/pom.xml | 4 ++ pom.xml | 6 +++ 5 files changed, 26 insertions(+), 40 deletions(-) diff --git a/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/config/SaTokenConfig.java b/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/config/SaTokenConfig.java index 9eb48fa9..06471950 100644 --- a/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/config/SaTokenConfig.java +++ b/iot-common/iot-common-satoken/src/main/java/cc/iotkit/common/satoken/config/SaTokenConfig.java @@ -11,6 +11,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import java.util.ArrayList; +import java.util.List; + /** * sa-token 配置 * @@ -39,8 +42,20 @@ public class SaTokenConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { // 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验。 + + List swaggerUrls = List.of("/doc.html","/favicon.ico", "/webjars/**", "/resources/**" + , "/swagger-resources/**", "/swagger-ui.html/**"); + + List loginUrls = List.of("/code", "/auth/tenant/list", "/auth/login"); + List openApiUrls = List.of( "/openapi/v1/getToken"); + + List excludeUrls = new ArrayList<>(); + excludeUrls.addAll(loginUrls); + excludeUrls.addAll(swaggerUrls); + excludeUrls.addAll(openApiUrls); + registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin())) .addPathPatterns("/**") - .excludePathPatterns("/code", "/auth/tenant/list", "/auth/login"); + .excludePathPatterns(excludeUrls); } } diff --git a/iot-module/iot-openapi/pom.xml b/iot-module/iot-openapi/pom.xml index dc1baf17..453c451c 100644 --- a/iot-module/iot-openapi/pom.xml +++ b/iot-module/iot-openapi/pom.xml @@ -13,36 +13,12 @@ - - org.springframework.boot - spring-boot-starter-web - - - - org.bouncycastle - bcprov-jdk15on - - - - com.aliyun.oss - aliyun-sdk-oss - joda-time joda-time - - it.ozimov - embedded-redis - - - slf4j-simple - org.slf4j - - - cc.iotkit @@ -59,20 +35,6 @@ iot-rule-engine - - cc.iotkit - iot-screen - - - - cc.iotkit - iot-component-server - - - - cc.iotkit - iot-component-converter - cc.iotkit diff --git a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenBaseController.java b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenBaseController.java index 7da850de..c62bdec3 100644 --- a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenBaseController.java +++ b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenBaseController.java @@ -4,7 +4,6 @@ import cc.iotkit.common.api.Request; import cc.iotkit.model.InvokeResult; import cc.iotkit.openapi.dto.bo.TokenVerifyBo; import cc.iotkit.openapi.service.OpenBaseService; -import cc.iotkit.openapi.service.OpenDeviceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; diff --git a/iot-starter/pom.xml b/iot-starter/pom.xml index dfe8ac2a..76bc3807 100644 --- a/iot-starter/pom.xml +++ b/iot-starter/pom.xml @@ -166,6 +166,10 @@ cc.iotkit iot-generator + + cc.iotkit + iot-openapi +