|
|
|
@ -18,6 +18,8 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
|
import org.springframework.web.filter.CommonsRequestLoggingFilter;
|
|
|
|
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
@ -27,7 +29,6 @@ import kr.xit.core.spring.config.auth.AuthentificationInterceptor;
|
|
|
|
|
import kr.xit.core.spring.config.properties.CorsProperties;
|
|
|
|
|
import kr.xit.core.spring.filter.LoggingFilter;
|
|
|
|
|
import kr.xit.core.spring.filter.ReadableRequestWrapperFilter;
|
|
|
|
|
import kr.xit.core.spring.filter.SimpleCORSFilter;
|
|
|
|
|
import kr.xit.core.spring.resolver.CustomArgumentResolver;
|
|
|
|
|
import kr.xit.core.spring.resolver.PageableArgumentResolver;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
@ -39,7 +40,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
* - AuthentificationInterceptor : 인증처리
|
|
|
|
|
* - CommonsRequestLoggingFilter : request logging
|
|
|
|
|
* - ReadableRequestWrapperFilter : post logging 처리를 위한 필터
|
|
|
|
|
* - SimpleCORSFilter : cors
|
|
|
|
|
* - CORS
|
|
|
|
|
* packageName : kr.xit.core.spring.config
|
|
|
|
|
* fileName : WebMvcConfig
|
|
|
|
|
* author : julim
|
|
|
|
@ -53,11 +54,11 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
* @see AuthentificationInterceptor
|
|
|
|
|
* @see CommonsRequestLoggingFilter
|
|
|
|
|
* @see ReadableRequestWrapperFilter
|
|
|
|
|
* @see SimpleCORSFilter
|
|
|
|
|
* @see LoggingFilter
|
|
|
|
|
*/
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Configuration
|
|
|
|
|
@EnableWebMvc
|
|
|
|
|
public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
|
/**
|
|
|
|
|
* logging exclude path
|
|
|
|
@ -73,7 +74,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
|
.addPathPatterns("/**/*")
|
|
|
|
|
.excludePathPatterns(
|
|
|
|
|
"/api/core/*"
|
|
|
|
|
// "/api/v1/kakaopay/*"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -92,7 +92,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
|
|
|
|
resolvers.add(new CustomArgumentResolver());
|
|
|
|
|
resolvers.add(new PageableArgumentResolver());
|
|
|
|
|
//WebMvcConfigurer.super.addArgumentResolvers(resolvers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -161,44 +160,16 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
|
return bean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* CORS Filter 등록
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public FilterRegistrationBean simpleCorsFilter() {
|
|
|
|
|
|
|
|
|
|
SimpleCORSFilter corsFilter = new SimpleCORSFilter();
|
|
|
|
|
FilterRegistrationBean bean = new FilterRegistrationBean(corsFilter);
|
|
|
|
|
bean.setOrder(Ordered.LOWEST_PRECEDENCE);
|
|
|
|
|
bean.addUrlPatterns(Constants.API_URL_PATTERNS);
|
|
|
|
|
return bean;
|
|
|
|
|
|
|
|
|
|
// CorsConfiguration config = new CorsConfiguration();
|
|
|
|
|
// config.setAllowedOrigins(Collections.singletonList(corsProperties.getAllowedOrigins()));
|
|
|
|
|
// config.setAllowedMethods(Collections.singletonList(corsProperties.getAllowedMethods()));
|
|
|
|
|
// config.setAllowedHeaders(Collections.singletonList(corsProperties.getAllowedHeaders()));
|
|
|
|
|
// config.setAllowCredentials(corsProperties.getAllowCredentials());
|
|
|
|
|
// config.setMaxAge(corsProperties.getMaxAge());
|
|
|
|
|
// config.setExposedHeaders(Collections.singletonList(corsProperties.getExposeHeader()));
|
|
|
|
|
//
|
|
|
|
|
// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
|
|
|
// source.registerCorsConfiguration("/**", config);
|
|
|
|
|
//
|
|
|
|
|
// FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
|
|
|
|
|
// bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
|
|
|
|
// return bean;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public void addCorsMappings(CorsRegistry registry) {
|
|
|
|
|
// //WebMvcConfigurer.super.addCorsMappings(registry);
|
|
|
|
|
// registry.addMapping("/**")
|
|
|
|
|
// .allowedOrigins(String.valueOf(Collections.singletonList(corsProperties.getAllowedOrigins())))
|
|
|
|
|
// .allowedMethods(String.valueOf(Collections.singletonList(corsProperties.getAllowedMethods())));
|
|
|
|
|
// }
|
|
|
|
|
@Override
|
|
|
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
|
|
|
registry.addMapping("/api/**")
|
|
|
|
|
.allowedOrigins(corsProperties.getAllowedOrigins().split(","))
|
|
|
|
|
.allowedMethods(corsProperties.getAllowedMethods().split(","))
|
|
|
|
|
.allowedHeaders(corsProperties.getAllowedHeaders().split(","))
|
|
|
|
|
.allowCredentials(corsProperties.getAllowCredentials())
|
|
|
|
|
.maxAge(corsProperties.getMaxAge())
|
|
|
|
|
.exposedHeaders(corsProperties.getExposeHeader());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|