From a966e1ba7f9c84e7a377f4f34b560e19205788cb Mon Sep 17 00:00:00 2001 From: "jiakun.lin" Date: Fri, 4 Jun 2021 10:59:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=A6=E6=88=AA=E6=94=B9=E4=B8=BA=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yipin/liuwanr/config/AuthConfig.java | 36 +++++++++++++++---- .../resources/application-keda.properties | 7 ++++ .../resources/application-prod.properties | 7 ++++ .../resources/application-test.properties | 7 ++++ .../application-test_keda.properties | 7 ++++ 5 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/yipin/liuwanr/config/AuthConfig.java b/src/main/java/com/yipin/liuwanr/config/AuthConfig.java index 376825b..a037081 100644 --- a/src/main/java/com/yipin/liuwanr/config/AuthConfig.java +++ b/src/main/java/com/yipin/liuwanr/config/AuthConfig.java @@ -1,20 +1,42 @@ package com.yipin.liuwanr.config; -/** - * @description - * @author: Mr.JK - * @create: 2021-06-03 16:24 - **/ + import com.yipin.liuwanr.filter.AuthInterceptor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; 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.List; + +/** + * @description + * @author: Mr.JK + * @create: 2021-06-03 16:24 + **/ @Configuration +@ConfigurationProperties(prefix = "auth") public class AuthConfig implements WebMvcConfigurer { + //开启拦截字符串 + public static String openInterceptStr; + + //放行url + public static List permitUrl; + + @Value("${auth.openInterceptStr}") + public void setOpenInterceptStr(String openInterceptStr) { + AuthConfig.openInterceptStr = openInterceptStr; + } + + @Value("${auth.permitUrl}") + public void setPermitUrl(List permitUrl) { + AuthConfig.permitUrl = permitUrl; + } + @Bean public AuthInterceptor initAuthInterceptor(){ return new AuthInterceptor(); @@ -22,8 +44,8 @@ public class AuthConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/**") - .excludePathPatterns("/userInfo/adminLogins/**","/userInfo/loginSchoolClient/**","/userInfo/logins/**","/userInfo/updateLogInNumber/**"); + registry.addInterceptor(initAuthInterceptor()).addPathPatterns(openInterceptStr) + .excludePathPatterns(permitUrl); } } \ No newline at end of file diff --git a/src/main/resources/application-keda.properties b/src/main/resources/application-keda.properties index fa02aba..751e510 100644 --- a/src/main/resources/application-keda.properties +++ b/src/main/resources/application-keda.properties @@ -47,3 +47,10 @@ spring.servlet.multipart.maxRequestSize=10240MB pagehelper.reasonable=false +#ȫ,Ϊղ +#auth.openInterceptStr= +auth.openInterceptStr=/** +#Url +auth.permitUrl=/userInfo/adminLogins/**,/userInfo/loginSchoolClient/**,/province/queryProvince/**,/city/queryCity/**,/customer/querySchool/**,/userInfo/queryPhone/** + + diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 7895a9e..4101d2a 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -47,3 +47,10 @@ spring.servlet.multipart.maxRequestSize=10240MB pagehelper.reasonable=false +#ȫ,Ϊղ +#auth.openInterceptStr= +auth.openInterceptStr=/** +#Url +auth.permitUrl=/userInfo/adminLogins/**,/userInfo/loginSchoolClient/**,/province/queryProvince/**,/city/queryCity/**,/customer/querySchool/**,/userInfo/queryPhone/** + + diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties index 3574706..e5f5ab9 100644 --- a/src/main/resources/application-test.properties +++ b/src/main/resources/application-test.properties @@ -47,3 +47,10 @@ spring.servlet.multipart.maxRequestSize=10240MB pagehelper.reasonable=false +#ȫ,Ϊղ +#auth.openInterceptStr= +auth.openInterceptStr=/** +#Url +auth.permitUrl=/userInfo/adminLogins/**,/userInfo/loginSchoolClient/**,/province/queryProvince/**,/city/queryCity/**,/customer/querySchool/**,/userInfo/queryPhone/** + + diff --git a/src/main/resources/application-test_keda.properties b/src/main/resources/application-test_keda.properties index a156057..9140623 100644 --- a/src/main/resources/application-test_keda.properties +++ b/src/main/resources/application-test_keda.properties @@ -47,3 +47,10 @@ spring.servlet.multipart.maxRequestSize=10240MB pagehelper.reasonable=false +#ȫ,Ϊղ +#auth.openInterceptStr= +auth.openInterceptStr=/** +#Url +auth.permitUrl=/userInfo/adminLogins/**,/userInfo/loginSchoolClient/**,/province/queryProvince/**,/city/queryCity/**,/customer/querySchool/**,/userInfo/queryPhone/** + +