|
|
@ -18,6 +18,8 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
import org.springframework.web.filter.CommonsRequestLoggingFilter;
|
|
|
|
import org.springframework.web.filter.CommonsRequestLoggingFilter;
|
|
|
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
|
|
|
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.InterceptorRegistry;
|
|
|
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
|
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
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.config.properties.CorsProperties;
|
|
|
|
import kr.xit.core.spring.filter.LoggingFilter;
|
|
|
|
import kr.xit.core.spring.filter.LoggingFilter;
|
|
|
|
import kr.xit.core.spring.filter.ReadableRequestWrapperFilter;
|
|
|
|
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.CustomArgumentResolver;
|
|
|
|
import kr.xit.core.spring.resolver.PageableArgumentResolver;
|
|
|
|
import kr.xit.core.spring.resolver.PageableArgumentResolver;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@ -39,7 +40,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
* - AuthentificationInterceptor : 인증처리
|
|
|
|
* - AuthentificationInterceptor : 인증처리
|
|
|
|
* - CommonsRequestLoggingFilter : request logging
|
|
|
|
* - CommonsRequestLoggingFilter : request logging
|
|
|
|
* - ReadableRequestWrapperFilter : post logging 처리를 위한 필터
|
|
|
|
* - ReadableRequestWrapperFilter : post logging 처리를 위한 필터
|
|
|
|
* - SimpleCORSFilter : cors
|
|
|
|
* - CORS
|
|
|
|
* packageName : kr.xit.core.spring.config
|
|
|
|
* packageName : kr.xit.core.spring.config
|
|
|
|
* fileName : WebMvcConfig
|
|
|
|
* fileName : WebMvcConfig
|
|
|
|
* author : julim
|
|
|
|
* author : julim
|
|
|
@ -53,11 +54,11 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
* @see AuthentificationInterceptor
|
|
|
|
* @see AuthentificationInterceptor
|
|
|
|
* @see CommonsRequestLoggingFilter
|
|
|
|
* @see CommonsRequestLoggingFilter
|
|
|
|
* @see ReadableRequestWrapperFilter
|
|
|
|
* @see ReadableRequestWrapperFilter
|
|
|
|
* @see SimpleCORSFilter
|
|
|
|
|
|
|
|
* @see LoggingFilter
|
|
|
|
* @see LoggingFilter
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
|
|
|
|
@EnableWebMvc
|
|
|
|
public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* logging exclude path
|
|
|
|
* logging exclude path
|
|
|
@ -73,7 +74,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
.addPathPatterns("/**/*")
|
|
|
|
.addPathPatterns("/**/*")
|
|
|
|
.excludePathPatterns(
|
|
|
|
.excludePathPatterns(
|
|
|
|
"/api/core/*"
|
|
|
|
"/api/core/*"
|
|
|
|
// "/api/v1/kakaopay/*"
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -92,7 +92,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
|
|
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
|
|
|
resolvers.add(new CustomArgumentResolver());
|
|
|
|
resolvers.add(new CustomArgumentResolver());
|
|
|
|
resolvers.add(new PageableArgumentResolver());
|
|
|
|
resolvers.add(new PageableArgumentResolver());
|
|
|
|
//WebMvcConfigurer.super.addArgumentResolvers(resolvers);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -161,46 +160,18 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
return bean;
|
|
|
|
return bean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@Override
|
|
|
|
* CORS Filter 등록
|
|
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
|
|
* @return
|
|
|
|
registry.addMapping("/api/**")
|
|
|
|
*/
|
|
|
|
.allowedOrigins(corsProperties.getAllowedOrigins().split(","))
|
|
|
|
@Bean
|
|
|
|
.allowedMethods(corsProperties.getAllowedMethods().split(","))
|
|
|
|
public FilterRegistrationBean simpleCorsFilter() {
|
|
|
|
.allowedHeaders(corsProperties.getAllowedHeaders().split(","))
|
|
|
|
|
|
|
|
.allowCredentials(corsProperties.getAllowCredentials())
|
|
|
|
SimpleCORSFilter corsFilter = new SimpleCORSFilter();
|
|
|
|
.maxAge(corsProperties.getMaxAge())
|
|
|
|
FilterRegistrationBean bean = new FilterRegistrationBean(corsFilter);
|
|
|
|
.exposedHeaders(corsProperties.getExposeHeader());
|
|
|
|
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())));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * HandlerExceptionResolver 를 상속받은 resolver 등록
|
|
|
|
// * HandlerExceptionResolver 를 상속받은 resolver 등록
|
|
|
|
// * @param resolvers the list of configured resolvers to extend
|
|
|
|
// * @param resolvers the list of configured resolvers to extend
|
|
|
|