|
@@ -1,41 +0,0 @@
|
|
|
-package cn.com.qmth.examcloud.core.basic.starter.config;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.commons.web.security.AccessCtrlInterceptor;
|
|
|
-
|
|
|
-/**
|
|
|
- * prod环境开启权限验证
|
|
|
- * @author ting.yin
|
|
|
- */
|
|
|
-@Configuration
|
|
|
-//@Profile("prod")
|
|
|
-public class AccessControlConfig extends WebMvcConfigurerAdapter {
|
|
|
-
|
|
|
- @SuppressWarnings("rawtypes")
|
|
|
- @Autowired
|
|
|
- RedisTemplate redisTemplate;
|
|
|
-
|
|
|
- @Bean
|
|
|
- public AccessCtrlInterceptor getInterceptor() {
|
|
|
- return new AccessCtrlInterceptor(redisTemplate);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void addInterceptors(InterceptorRegistry registry) {
|
|
|
- registry.addInterceptor(getInterceptor()).addPathPatterns("/**").excludePathPatterns("/**/swagger-ui.html#/**");
|
|
|
- }
|
|
|
- @Override
|
|
|
- public void addCorsMappings(CorsRegistry registry) {
|
|
|
- registry.addMapping("/**")
|
|
|
- .allowedOrigins("*")
|
|
|
- .allowedMethods("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "TRACE")
|
|
|
- .allowedHeaders("*");
|
|
|
- }
|
|
|
-}
|