xyz.erupt.security.config.MvcInterceptor Maven / Gradle / Ivy
package xyz.erupt.security.config;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
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 xyz.erupt.core.constant.EruptRestPath;
import xyz.erupt.security.interceptor.EruptSecurityInterceptor;
import xyz.erupt.security.interceptor.EruptSuperInterceptor;
import xyz.erupt.security.interceptor.HttpServletRequestFilter;
import javax.annotation.Resource;
/**
* @author YuePeng
* date 2018-12-20.
*/
@Configuration
public class MvcInterceptor implements WebMvcConfigurer {
@Resource
private EruptSecurityInterceptor eruptSecurityInterceptor;
@Resource
private EruptSuperInterceptor eruptSuperInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(eruptSuperInterceptor).addPathPatterns("/**");
registry.addInterceptor(eruptSecurityInterceptor).addPathPatterns(EruptRestPath.ERUPT_API + "/**");
}
@Bean
public FilterRegistrationBean registerAuthFilter(EruptSecurityProp eruptSecurityProp) {
FilterRegistrationBean registration = new FilterRegistrationBean<>();
registration.setFilter(new HttpServletRequestFilter(eruptSecurityProp));
registration.addUrlPatterns(EruptRestPath.ERUPT_API + "/*");
registration.setName(HttpServletRequestFilter.class.getSimpleName());
registration.setOrder(1);
return registration;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy