[api] swagger 셋팅중
- cors 화이트리스트 허용방식 변경
This commit is contained in:
@@ -1,41 +1,31 @@
|
||||
package com.alist.api.config;
|
||||
|
||||
import com.alist.api.config.properties.CorsProperties;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(CorsProperties.class)
|
||||
@RequiredArgsConstructor
|
||||
public class CorsConfig {
|
||||
|
||||
private final CorsProperties corsProperties;
|
||||
|
||||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
|
||||
configuration.setAllowedOrigins(Arrays.asList(
|
||||
"http://localhost",
|
||||
"http://localhost:8100",
|
||||
"http://localhost:8101",
|
||||
"http://localhost:8102",
|
||||
"http://localhost:8103",
|
||||
"http://localhost:8104",
|
||||
"http://localhost:8105",
|
||||
"https://wwwl-alist.pjt.kr",
|
||||
"https://engl-alist.pjt.kr",
|
||||
"https://admin-alist.pjt.kr",
|
||||
"https://wwwc-alist.pjt.kr",
|
||||
"https://class-alist.pjt.kr",
|
||||
"https://student-alist.pjt.kr"
|
||||
));
|
||||
|
||||
configuration.setAllowCredentials(true);
|
||||
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
|
||||
configuration.setAllowedHeaders(Arrays.asList("*"));
|
||||
configuration.setExposedHeaders(Arrays.asList("Authorization", "Set-Cookie"));
|
||||
configuration.setMaxAge(3600L);
|
||||
configuration.setAllowedOrigins(corsProperties.getAllowedOrigins());
|
||||
configuration.setAllowCredentials(corsProperties.getAllowCredentials());
|
||||
configuration.setAllowedMethods(corsProperties.getAllowedMethods());
|
||||
configuration.setAllowedHeaders(corsProperties.getAllowedHeaders());
|
||||
configuration.setExposedHeaders(corsProperties.getExposedHeaders());
|
||||
configuration.setMaxAge(corsProperties.getMaxAge());
|
||||
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.alist.api.config.properties;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ConfigurationProperties(prefix = "cors")
|
||||
public class CorsProperties {
|
||||
List<String> allowedOrigins;
|
||||
Boolean allowCredentials = true;
|
||||
List<String> allowedMethods = List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS");
|
||||
List<String> allowedHeaders = List.of("*");
|
||||
List<String> exposedHeaders = List.of("Authorization", "Set-Cookie");
|
||||
Long maxAge = 3600L;
|
||||
}
|
||||
@@ -18,6 +18,16 @@ jwt:
|
||||
cookie:
|
||||
secure: false # 로컬 개발 환경 (HTTP)
|
||||
|
||||
cors:
|
||||
allowed-origins:
|
||||
- "http://localhost:8100"
|
||||
- "http://localhost:8101"
|
||||
- "http://localhost:8102"
|
||||
- "http://localhost:8103"
|
||||
- "http://localhost:8104"
|
||||
- "http://localhost:8105"
|
||||
- "http://localhost:8108"
|
||||
|
||||
swagger:
|
||||
login:
|
||||
id: alist
|
||||
|
||||
@@ -20,6 +20,24 @@ jwt:
|
||||
cookie:
|
||||
secure: true # 프로젝트 환경 (HTTPS)
|
||||
|
||||
cors:
|
||||
allowed-origins:
|
||||
- "http://localhost"
|
||||
- "http://localhost:8100"
|
||||
- "http://localhost:8101"
|
||||
- "http://localhost:8102"
|
||||
- "http://localhost:8103"
|
||||
- "http://localhost:8104"
|
||||
- "http://localhost:8105"
|
||||
- "http://localhost:8108"
|
||||
- "https://wwwl-alist.pjt.kr"
|
||||
- "https://engl-alist.pjt.kr"
|
||||
- "https://admin-alist.pjt.kr"
|
||||
- "https://wwwc-alist.pjt.kr"
|
||||
- "https://class-alist.pjt.kr"
|
||||
- "https://student-alist.pjt.kr"
|
||||
- "https://storybook-alist.pjt.kr"
|
||||
|
||||
swagger:
|
||||
login:
|
||||
id: ${SWAGGER_ID}
|
||||
|
||||
Reference in New Issue
Block a user