|
@@ -1,55 +0,0 @@
|
|
-package cn.com.qmth.examcloud.core.questions.starter;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
|
|
|
|
-import cn.com.qmth.examcloud.commons.web.security.AccessCtrlInterceptor;
|
|
|
|
-
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
-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 org.springframework.core.convert.converter.Converter;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * prod环境开启权限验证
|
|
|
|
- * Created by yuanpan on 2017/4/13.
|
|
|
|
- */
|
|
|
|
-@Configuration
|
|
|
|
-//@Profile("prod")
|
|
|
|
-public class AccessControlConfig extends WebMvcConfigurerAdapter implements Converter<String,ExamType> {
|
|
|
|
-
|
|
|
|
- @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("*");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public ExamType convert(String source) {
|
|
|
|
- if(StringUtils.isBlank(source)){
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- return ExamType.valueOf(source);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-}
|
|
|