1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package com.persagy.proxy.common.config;
- import com.persagy.dmp.auth.client.EmsSaasWebFallbackFactory;
- import com.persagy.dmp.auth.handler.AppContextHandler;
- import com.persagy.dmp.auth.service.AuthService;
- import com.persagy.proxy.common.service.impl.EmsAuthServiceImpl;
- import com.persagy.proxy.common.service.impl.NoneAuthServiceImpl;
- import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.core.annotation.Order;
- import org.springframework.scheduling.annotation.EnableAsync;
- import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
- /**
- * 拦截器
- * @author Charlie Yu
- * @date 2021-09-13
- */
- @Configuration
- @Order(1)
- @EnableAsync
- public class AdmMiddlewareWebConfigurer implements WebMvcConfigurer {
- @Bean
- public AppContextHandler appContextHandler() {
- return new AppContextHandler();
- }
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- String[] includePaths = {"/**"};
- String[] excludePaths = {"/**/*.html", "/**/*.js", "/**/*.css", "/swagger-resources"};
- // 设置拦截的路径、不拦截的路径、优先级等等
- registry.addInterceptor(appContextHandler()).order(11).addPathPatterns(includePaths).excludePathPatterns(excludePaths);
- }
- @Bean
- @ConditionalOnProperty(value = "persagy.common.auth.channel", havingValue = "1")
- public EmsSaasWebFallbackFactory emsSaasWebFallbackFactory(){
- return new EmsSaasWebFallbackFactory();
- }
- @Bean
- @ConditionalOnProperty(value = "persagy.common.auth.channel", havingValue = "1")
- public AuthService emsAuthServiceImpl(){
- return new EmsAuthServiceImpl();
- }
- @Bean
- @ConditionalOnProperty(value = "persagy.common.auth.channel", havingValue = "-1",matchIfMissing = true)
- public AuthService noneAuthServiceImpl(){
- return new NoneAuthServiceImpl();
- }
- }
|