From a7d7e851a90e5c751b71ec779e6ed83cdb002bad Mon Sep 17 00:00:00 2001 From: KNU-K Date: Tue, 12 Aug 2025 15:06:47 +0900 Subject: [PATCH 1/3] feat: add ProfileUtil for managing active profiles and update cookie security based on environment --- .../mosuserver/MosuServerApplication.java | 13 +++++++- .../global/util/CookieBuilderUtil.java | 4 ++- .../mosuserver/global/util/ProfileUtil.java | 32 +++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/main/java/life/mosu/mosuserver/global/util/ProfileUtil.java diff --git a/src/main/java/life/mosu/mosuserver/MosuServerApplication.java b/src/main/java/life/mosu/mosuserver/MosuServerApplication.java index ea49db4f..28c2cc35 100644 --- a/src/main/java/life/mosu/mosuserver/MosuServerApplication.java +++ b/src/main/java/life/mosu/mosuserver/MosuServerApplication.java @@ -1,12 +1,23 @@ package life.mosu.mosuserver; +import life.mosu.mosuserver.global.util.ProfileUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class MosuServerApplication { +@Slf4j +public class MosuServerApplication implements CommandLineRunner { public static void main(String[] args) { SpringApplication.run(MosuServerApplication.class, args); } + + @Override + public void run(String... args) throws Exception { + log.info("Active Profiles: {}", (Object) ProfileUtil.getActiveProfilesStatic()); + log.info("profile : {}", ProfileUtil.isProfileActiveStatic("prod")); + log.info("profile : {}", ProfileUtil.isProfileActiveStatic("test")); + } } diff --git a/src/main/java/life/mosu/mosuserver/global/util/CookieBuilderUtil.java b/src/main/java/life/mosu/mosuserver/global/util/CookieBuilderUtil.java index 7f5ea9aa..384d13f4 100644 --- a/src/main/java/life/mosu/mosuserver/global/util/CookieBuilderUtil.java +++ b/src/main/java/life/mosu/mosuserver/global/util/CookieBuilderUtil.java @@ -64,8 +64,10 @@ public static String createLocalCookieString(String name, String value, Long max */ public static ResponseCookie createDevelopResponseCookie(String name, String value, Long maxAge) { + boolean isProd = ProfileUtil.isProfileActiveStatic("prod"); + return createBaseResponseCookieBuilder(name, value, maxAge) - .secure(true) + .secure(isProd) .domain(".mosuedu.com") .sameSite("Strict") .build(); diff --git a/src/main/java/life/mosu/mosuserver/global/util/ProfileUtil.java b/src/main/java/life/mosu/mosuserver/global/util/ProfileUtil.java new file mode 100644 index 00000000..63f53e79 --- /dev/null +++ b/src/main/java/life/mosu/mosuserver/global/util/ProfileUtil.java @@ -0,0 +1,32 @@ +package life.mosu.mosuserver.global.util; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class ProfileUtil implements ApplicationContextAware { + + private static Environment environment; + + public static String[] getActiveProfilesStatic() { + return environment.getActiveProfiles(); + } + + public static boolean isProfileActiveStatic(String profile) { + for (String active : environment.getActiveProfiles()) { + if (active.equals(profile)) { + return true; + } + } + return false; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + environment = applicationContext.getEnvironment(); + } +} + From caa120dc1329226cadd6e859faff75eb3ab5134d Mon Sep 17 00:00:00 2001 From: KNU-K Date: Tue, 12 Aug 2025 15:06:56 +0900 Subject: [PATCH 2/3] feat: update self-deploy.yaml to trigger on push to develop branch --- .github/workflows/self-depoly.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/self-depoly.yaml b/.github/workflows/self-depoly.yaml index 56beca69..cf423d0f 100644 --- a/.github/workflows/self-depoly.yaml +++ b/.github/workflows/self-depoly.yaml @@ -1,9 +1,9 @@ name: Docker CI/CD - Deploy on: + push: + branches: [ develop ] workflow_dispatch: - branches: - - develop jobs: deploy: runs-on: self-hosted From 1ef2cc53f0670b3620c5664117c03fcbf471fdca Mon Sep 17 00:00:00 2001 From: KNU-K Date: Tue, 12 Aug 2025 16:12:03 +0900 Subject: [PATCH 3/3] fix: remove unnecessary string replacement in phone number retrieval --- .../life/mosu/mosuserver/application/notify/NotifyService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/life/mosu/mosuserver/application/notify/NotifyService.java b/src/main/java/life/mosu/mosuserver/application/notify/NotifyService.java index 1b5c0d10..d09b35be 100644 --- a/src/main/java/life/mosu/mosuserver/application/notify/NotifyService.java +++ b/src/main/java/life/mosu/mosuserver/application/notify/NotifyService.java @@ -32,7 +32,7 @@ public class NotifyService { retryFor = {CustomRuntimeException.class} ) public void notify(LunaNotificationEvent event) { - String phone = retrievePhoneNumberByUserId(event.userId()).replaceFirst("^.", ""); + String phone = retrievePhoneNumberByUserId(event.userId()); LunaNotificationVariable notifyVariable = notifyVariableFactory.create(event); NotifySender sender = senderResolver.resolve(event.status());