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/** + +