From 8be095e2d884fe1a3654691003f6fe61cc484f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=8F=99=ED=9B=88?= <2dh2@naver.com> Date: Fri, 24 Apr 2026 11:31:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EC=9A=B4=EC=98=81=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EC=97=90=EC=84=9C=20Swagger=EB=A5=BC=20=EB=B9=84?= =?UTF-8?q?=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 운영 서버에서 API 명세와 Swagger UI가 외부에 노출되지 않도록 prod 프로필에서 springdoc을 끈다 - Swagger 관련 Bean과 커스텀 initializer 컨트롤러도 prod에서는 생성되지 않게 막아 우회 노출 가능성을 줄인다 - stage/local 개발 편의성은 유지하고, 운영 환경에만 최소 범위로 적용한다 --- .../java/gg/agit/konect/global/config/SwaggerConfig.java | 2 ++ .../konect/global/config/SwaggerUiResourceController.java | 2 ++ src/main/resources/application-prod.yml | 5 +++++ 3 files changed, 9 insertions(+) create mode 100644 src/main/resources/application-prod.yml diff --git a/src/main/java/gg/agit/konect/global/config/SwaggerConfig.java b/src/main/java/gg/agit/konect/global/config/SwaggerConfig.java index d26ce1129..a2d8568aa 100644 --- a/src/main/java/gg/agit/konect/global/config/SwaggerConfig.java +++ b/src/main/java/gg/agit/konect/global/config/SwaggerConfig.java @@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springdoc.core.models.GroupedOpenApi; @@ -16,6 +17,7 @@ import io.swagger.v3.oas.models.servers.Server; @Configuration +@Profile("!prod") public class SwaggerConfig { private final String serverUrl; diff --git a/src/main/java/gg/agit/konect/global/config/SwaggerUiResourceController.java b/src/main/java/gg/agit/konect/global/config/SwaggerUiResourceController.java index 3253d9472..247b69b19 100644 --- a/src/main/java/gg/agit/konect/global/config/SwaggerUiResourceController.java +++ b/src/main/java/gg/agit/konect/global/config/SwaggerUiResourceController.java @@ -2,6 +2,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import org.springframework.context.annotation.Profile; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -11,6 +12,7 @@ @Hidden @RestController +@Profile("!prod") public class SwaggerUiResourceController { private static final String SWAGGER_INITIALIZER_PATH = "static/swagger-ui/swagger-initializer.js"; diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 000000000..7b9828578 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,5 @@ +springdoc: + api-docs: + enabled: false + swagger-ui: + enabled: false From 4f14177301723047c917cf064a9780b8a3cc7067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=8F=99=ED=9B=88?= <2dh2@naver.com> Date: Fri, 24 Apr 2026 11:31:53 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=EC=BD=94=EB=93=9C=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=B7=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/gg/agit/konect/global/config/SwaggerConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gg/agit/konect/global/config/SwaggerConfig.java b/src/main/java/gg/agit/konect/global/config/SwaggerConfig.java index a2d8568aa..e6b9986e0 100644 --- a/src/main/java/gg/agit/konect/global/config/SwaggerConfig.java +++ b/src/main/java/gg/agit/konect/global/config/SwaggerConfig.java @@ -60,8 +60,8 @@ public GroupedOpenApi publicApi() { .addOpenApiCustomizer(openApi -> openApi.setTags( openApi.getTags() != null ? openApi.getTags().stream() - .sorted((a, b) -> a.getName().compareTo(b.getName())) - .toList() + .sorted((a, b) -> a.getName().compareTo(b.getName())) + .toList() : null )) .build();