|
|
@ -1,20 +1,42 @@ |
|
|
|
package com.yipin.liuwanr.config; |
|
|
|
package com.yipin.liuwanr.config; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @description |
|
|
|
|
|
|
|
* @author: Mr.JK |
|
|
|
|
|
|
|
* @create: 2021-06-03 16:24 |
|
|
|
|
|
|
|
**/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.yipin.liuwanr.filter.AuthInterceptor; |
|
|
|
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.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @description |
|
|
|
|
|
|
|
* @author: Mr.JK |
|
|
|
|
|
|
|
* @create: 2021-06-03 16:24 |
|
|
|
|
|
|
|
**/ |
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
|
|
|
|
@ConfigurationProperties(prefix = "auth") |
|
|
|
public class AuthConfig implements WebMvcConfigurer { |
|
|
|
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 |
|
|
|
@Bean |
|
|
|
public AuthInterceptor initAuthInterceptor(){ |
|
|
|
public AuthInterceptor initAuthInterceptor(){ |
|
|
|
return new AuthInterceptor(); |
|
|
|
return new AuthInterceptor(); |
|
|
@ -22,8 +44,8 @@ public class AuthConfig implements WebMvcConfigurer { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void addInterceptors(InterceptorRegistry registry) { |
|
|
|
public void addInterceptors(InterceptorRegistry registry) { |
|
|
|
registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/**") |
|
|
|
registry.addInterceptor(initAuthInterceptor()).addPathPatterns(openInterceptStr) |
|
|
|
.excludePathPatterns("/userInfo/adminLogins/**","/userInfo/loginSchoolClient/**","/userInfo/logins/**","/userInfo/updateLogInNumber/**"); |
|
|
|
.excludePathPatterns(permitUrl); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |