1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package cn.efunbox.audio.config;
- import cn.efunbox.audio.aop.AdminInterceptor;
- import cn.efunbox.audio.aop.AuthInterceptor;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.EnvironmentAware;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.ComponentScan;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.core.env.Environment;
- import org.springframework.web.cors.CorsConfiguration;
- import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
- import org.springframework.web.filter.CorsFilter;
- import org.springframework.web.servlet.config.annotation.EnableWebMvc;
- import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
- /**
- * 用户权限验证拦截器
- * Created by yao on 17-9-29.
- */
- @Configuration
- @EnableWebMvc
- public class Config extends WebMvcConfigurerAdapter{
- /**
- * 直接采用new interceptor或Autowired注入拦截器会导致dao为null的错误
- * @return
- */
- @Bean
- AuthInterceptor authInterceptor(){
- return new AuthInterceptor();
- }
- @Bean
- AdminInterceptor adminInterceptor(){
- return new AdminInterceptor();
- }
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(authInterceptor())
- .addPathPatterns("/audio/search");
- registry.addInterceptor(adminInterceptor())
- .addPathPatterns("/**")
- .excludePathPatterns("/device/**", "/admin/**", "/audio/search");
- }
- }
|