|
|
|
@ -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<String> permitUrl; |
|
|
|
|
|
|
|
|
|
@Value("${auth.openInterceptStr}") |
|
|
|
|
public void setOpenInterceptStr(String openInterceptStr) { |
|
|
|
|
AuthConfig.openInterceptStr = openInterceptStr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Value("${auth.permitUrl}") |
|
|
|
|
public void setPermitUrl(List<String> 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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |