From df949e5373ad6848d51d224fc62a72345f9802fe Mon Sep 17 00:00:00 2001 From: Oh YoungJe Date: Tue, 24 Sep 2024 15:32:02 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[SBL-150]=20=EB=A6=AC=ED=8C=A9=ED=84=B0?= =?UTF-8?q?=EB=A7=81=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/util/RandomNicknameGenerator.kt | 248 +++++++++--------- .../sulmun2yong/global/util/ResetSession.kt | 34 ++- .../global/util/SessionRegistryCleaner.kt | 22 +- 3 files changed, 149 insertions(+), 155 deletions(-) diff --git a/src/main/kotlin/com/sbl/sulmun2yong/global/util/RandomNicknameGenerator.kt b/src/main/kotlin/com/sbl/sulmun2yong/global/util/RandomNicknameGenerator.kt index 6182a150..17c41da1 100644 --- a/src/main/kotlin/com/sbl/sulmun2yong/global/util/RandomNicknameGenerator.kt +++ b/src/main/kotlin/com/sbl/sulmun2yong/global/util/RandomNicknameGenerator.kt @@ -2,133 +2,131 @@ package com.sbl.sulmun2yong.global.util import kotlin.random.Random -class RandomNicknameGenerator { - companion object { - fun generate(): String { - val positiveAdjective = getRandomPositiveAdjective() - val animalName = getRandomAnimalName() - return "$positiveAdjective $animalName" - } +object RandomNicknameGenerator { + fun generate(): String { + val positiveAdjective = getRandomPositiveAdjective() + val animalName = getRandomAnimalName() + return "$positiveAdjective $animalName" + } - private fun getRandomPositiveAdjective(): String { - val randomIndex = Random.nextInt(positiveAdjectives.size) - return positiveAdjectives[randomIndex] - } + private fun getRandomPositiveAdjective(): String { + val randomIndex = Random.nextInt(positiveAdjectives.size) + return positiveAdjectives[randomIndex] + } - private fun getRandomAnimalName(): String { - val randomIndex = Random.nextInt(animalNames.size) - return animalNames[randomIndex] - } + private fun getRandomAnimalName(): String { + val randomIndex = Random.nextInt(animalNames.size) + return animalNames[randomIndex] + } - private val positiveAdjectives = - listOf( - "멋진", - "아름다운", - "사랑스러운", - "기분 좋은", - "활기찬", - "행복한", - "용감한", - "현명한", - "똑똑한", - "친절한", - "따뜻한", - "차분한", - "건강한", - "잘생긴", - "매력적인", - "유쾌한", - "긍정적인", - "발랄한", - "자유로운", - "훌륭한", - "빛나는", - "깨끗한", - "상쾌한", - "풍부한", - "고운", - "순수한", - "평온한", - "친절한", - "재치 있는", - "유머러스한", - "사려 깊은", - "활발한", - "열정적인", - "끈기 있는", - "적극적인", - "신나는", - "흥미로운", - "놀라운", - "기대되는", - "즐거운", - "기쁜", - "자랑스러운", - "감동적인", - "성실한", - "충실한", - "헌신적인", - "열정있는", - ) + private val positiveAdjectives = + listOf( + "멋진", + "아름다운", + "사랑스러운", + "기분 좋은", + "활기찬", + "행복한", + "용감한", + "현명한", + "똑똑한", + "친절한", + "따뜻한", + "차분한", + "건강한", + "잘생긴", + "매력적인", + "유쾌한", + "긍정적인", + "발랄한", + "자유로운", + "훌륭한", + "빛나는", + "깨끗한", + "상쾌한", + "풍부한", + "고운", + "순수한", + "평온한", + "친절한", + "재치 있는", + "유머러스한", + "사려 깊은", + "활발한", + "열정적인", + "끈기 있는", + "적극적인", + "신나는", + "흥미로운", + "놀라운", + "기대되는", + "즐거운", + "기쁜", + "자랑스러운", + "감동적인", + "성실한", + "충실한", + "헌신적인", + "열정있는", + ) - private val animalNames = - listOf( - "고양이", - "강아지", - "코끼리", - "기린", - "사자", - "호랑이", - "곰", - "늑대", - "여우", - "토끼", - "사슴", - "원숭이", - "판다", - "코알라", - "캥거루", - "말", - "소", - "양", - "염소", - "닭", - "오리", - "거위", - "공작", - "앵무새", - "독수리", - "매", - "올빼미", - "참새", - "비둘기", - "까마귀", - "까치", - "두루미", - "황새", - "치타", - "하마", - "악어", - "두더지", - "수달", - "다람쥐", - "너구리", - "사막여우", - "라쿤", - "뱀", - "도마뱀", - "거북이", - "펭귄", - "돌고래", - "용", - "표범", - "고래", - "부엉이", - "타조", - "코뿔소", - "물개", - "고슴도치", - "카멜레온", - ) - } + private val animalNames = + listOf( + "고양이", + "강아지", + "코끼리", + "기린", + "사자", + "호랑이", + "곰", + "늑대", + "여우", + "토끼", + "사슴", + "원숭이", + "판다", + "코알라", + "캥거루", + "말", + "소", + "양", + "염소", + "닭", + "오리", + "거위", + "공작", + "앵무새", + "독수리", + "매", + "올빼미", + "참새", + "비둘기", + "까마귀", + "까치", + "두루미", + "황새", + "치타", + "하마", + "악어", + "두더지", + "수달", + "다람쥐", + "너구리", + "사막여우", + "라쿤", + "뱀", + "도마뱀", + "거북이", + "펭귄", + "돌고래", + "용", + "표범", + "고래", + "부엉이", + "타조", + "코뿔소", + "물개", + "고슴도치", + "카멜레온", + ) } diff --git a/src/main/kotlin/com/sbl/sulmun2yong/global/util/ResetSession.kt b/src/main/kotlin/com/sbl/sulmun2yong/global/util/ResetSession.kt index 064dd2e7..f21d49db 100644 --- a/src/main/kotlin/com/sbl/sulmun2yong/global/util/ResetSession.kt +++ b/src/main/kotlin/com/sbl/sulmun2yong/global/util/ResetSession.kt @@ -4,25 +4,23 @@ import jakarta.servlet.http.Cookie import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse -class ResetSession { - companion object { - fun reset( - request: HttpServletRequest, - response: HttpServletResponse, - ) { - // 세션 무효화 - request.session.invalidate() +object ResetSession { + fun reset( + request: HttpServletRequest, + response: HttpServletResponse, + ) { + // 세션 무효화 + request.session.invalidate() - // 쿠키 삭제 - val expiredJsessionIdCookie = Cookie("JSESSIONID", null) - expiredJsessionIdCookie.path = "/" - expiredJsessionIdCookie.maxAge = 0 - response.addCookie(expiredJsessionIdCookie) + // 쿠키 삭제 + val expiredJsessionIdCookie = Cookie("JSESSIONID", null) + expiredJsessionIdCookie.path = "/" + expiredJsessionIdCookie.maxAge = 0 + response.addCookie(expiredJsessionIdCookie) - val expiredUserProfileCookie = Cookie("user-profile", null) - expiredUserProfileCookie.path = "/" - expiredUserProfileCookie.maxAge = 0 - response.addCookie(expiredUserProfileCookie) - } + val expiredUserProfileCookie = Cookie("user-profile", null) + expiredUserProfileCookie.path = "/" + expiredUserProfileCookie.maxAge = 0 + response.addCookie(expiredUserProfileCookie) } } diff --git a/src/main/kotlin/com/sbl/sulmun2yong/global/util/SessionRegistryCleaner.kt b/src/main/kotlin/com/sbl/sulmun2yong/global/util/SessionRegistryCleaner.kt index a2f5860f..dd30c789 100644 --- a/src/main/kotlin/com/sbl/sulmun2yong/global/util/SessionRegistryCleaner.kt +++ b/src/main/kotlin/com/sbl/sulmun2yong/global/util/SessionRegistryCleaner.kt @@ -3,17 +3,15 @@ package com.sbl.sulmun2yong.global.util import org.springframework.security.core.Authentication import org.springframework.security.core.session.SessionRegistry -class SessionRegistryCleaner { - companion object { - fun removeSessionByAuthentication( - sessionRegistry: SessionRegistry, - authentication: Authentication, - ) { - sessionRegistry - .getAllSessions(authentication.principal, false) - .forEach { sessionInformation -> - sessionRegistry.removeSessionInformation(sessionInformation.sessionId) - } - } +object SessionRegistryCleaner { + fun removeSessionByAuthentication( + sessionRegistry: SessionRegistry, + authentication: Authentication, + ) { + sessionRegistry + .getAllSessions(authentication.principal, false) + .forEach { sessionInformation -> + sessionRegistry.removeSessionInformation(sessionInformation.sessionId) + } } } From b1545ca3156f1dc5171815c9bb7231b617844706 Mon Sep 17 00:00:00 2001 From: Oh YoungJe Date: Thu, 26 Sep 2024 01:14:42 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[SBL-150]=20=EC=8B=9C=ED=81=90=EB=A6=AC?= =?UTF-8?q?=ED=8B=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sbl/sulmun2yong/global/config/SecurityConfig.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt b/src/main/kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt index ddc76ecc..439fe5d6 100644 --- a/src/main/kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt +++ b/src/main/kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt @@ -122,10 +122,10 @@ class SecurityConfig( authorizeHttpRequests { authorize("/api/v1/admin/**", hasRole("ADMIN")) authorize("/api/v1/user/**", authenticated) + authorize("/api/v1/surveys/my-page", authenticated) authorize("/api/v1/surveys/results/**", authenticated) authorize("/api/v1/s3/**", authenticated) - authorize("/api/v1/surveys/my-page", authenticated) - authorize("/api/v1/surveys/participants/**", authenticated) + authorize("/api/v1/ai/*", authenticated) // TODO: 추후에 AUTHENTICATED_USER 로 수정 authorize("/api/v1/surveys/workbench/**", hasRole("ADMIN")) authorize("/**", permitAll) From 7fd4aedff23d987ba3a3805fabdf34aad4efea5f Mon Sep 17 00:00:00 2001 From: Oh YoungJe Date: Thu, 26 Sep 2024 01:33:56 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[SBL-150]=20**=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt b/src/main/kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt index 439fe5d6..97ad5a28 100644 --- a/src/main/kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt +++ b/src/main/kotlin/com/sbl/sulmun2yong/global/config/SecurityConfig.kt @@ -125,7 +125,7 @@ class SecurityConfig( authorize("/api/v1/surveys/my-page", authenticated) authorize("/api/v1/surveys/results/**", authenticated) authorize("/api/v1/s3/**", authenticated) - authorize("/api/v1/ai/*", authenticated) + authorize("/api/v1/ai/**", authenticated) // TODO: 추후에 AUTHENTICATED_USER 로 수정 authorize("/api/v1/surveys/workbench/**", hasRole("ADMIN")) authorize("/**", permitAll) From 66119c62cb297711cde76eb856f597f3f11bbf51 Mon Sep 17 00:00:00 2001 From: Oh YoungJe Date: Thu, 26 Sep 2024 13:34:08 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[SBL-150]=20AI=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 46f31d26..b182d725 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -37,7 +37,7 @@ backend: base-url: http://localhost:8080 ai-server: - base-url: http://localhost:8000 + base-url: http://ai.sulmoon.io cloudfront: base-url: https://files.sulmoon.io