From 57a42ea7fc975c92d44fd5d980117aee8b1402e7 Mon Sep 17 00:00:00 2001 From: jyajoo Date: Mon, 28 Oct 2024 03:11:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[#466]=20feat:=20cors=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/config/SecurityConfig.java | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/main/java/com/jeju/nanaland/global/config/SecurityConfig.java b/src/main/java/com/jeju/nanaland/global/config/SecurityConfig.java index d70b33b1..4f4542b8 100644 --- a/src/main/java/com/jeju/nanaland/global/config/SecurityConfig.java +++ b/src/main/java/com/jeju/nanaland/global/config/SecurityConfig.java @@ -19,9 +19,6 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.CorsConfigurationSource; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; @Configuration @EnableWebSecurity @@ -40,7 +37,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http, .httpBasic(AbstractHttpConfigurer::disable) .formLogin(AbstractHttpConfigurer::disable) .logout(AbstractHttpConfigurer::disable) - .cors(cors -> cors.configurationSource(corsConfigurationSource())) + .cors(AbstractHttpConfigurer::disable) .headers(c -> c.frameOptions( FrameOptionsConfig::disable).disable()) .sessionManagement(c -> @@ -83,21 +80,4 @@ public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } - @Bean - public CorsConfigurationSource corsConfigurationSource() { - CorsConfiguration configuration = new CorsConfiguration(); - - configuration.addAllowedOrigin("http://13.125.110.80:8083"); - configuration.addAllowedOrigin("https://nanaland.site"); - - configuration.setAllowCredentials(true); - configuration.addAllowedHeader("*"); - configuration.addAllowedMethod("*"); - configuration.setMaxAge(3600L); - - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - source.registerCorsConfiguration("/**", configuration); - - return source; - } } From 5bccf5c9ff9b213ed6b66875073dde6acf16fb8d Mon Sep 17 00:00:00 2001 From: jyajoo Date: Mon, 28 Oct 2024 03:27:16 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[#466]=20feat:=20swagger=20URL=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jeju/nanaland/global/config/SwaggerConfig.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/jeju/nanaland/global/config/SwaggerConfig.java b/src/main/java/com/jeju/nanaland/global/config/SwaggerConfig.java index 1184e77b..6d27ebf8 100644 --- a/src/main/java/com/jeju/nanaland/global/config/SwaggerConfig.java +++ b/src/main/java/com/jeju/nanaland/global/config/SwaggerConfig.java @@ -1,5 +1,7 @@ package com.jeju.nanaland.global.config; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.servers.Server; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; @@ -9,6 +11,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +@OpenAPIDefinition( + servers = { + @Server(url = "http://13.125.110.80:8083", description = "DEV"), + @Server(url = "https://nanaland.site", description = "PROD"), + @Server(url = "http://localhost:8080", description = "LOCAL") + } +) @Configuration public class SwaggerConfig {