Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SBL-150] object class로의 리팩터링 #69

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"고양이",
"강아지",
"코끼리",
"기린",
"사자",
"호랑이",
"곰",
"늑대",
"여우",
"토끼",
"사슴",
"원숭이",
"판다",
"코알라",
"캥거루",
"말",
"소",
"양",
"염소",
"닭",
"오리",
"거위",
"공작",
"앵무새",
"독수리",
"매",
"올빼미",
"참새",
"비둘기",
"까마귀",
"까치",
"두루미",
"황새",
"치타",
"하마",
"악어",
"두더지",
"수달",
"다람쥐",
"너구리",
"사막여우",
"라쿤",
"뱀",
"도마뱀",
"거북이",
"펭귄",
"돌고래",
"용",
"표범",
"고래",
"부엉이",
"타조",
"코뿔소",
"물개",
"고슴도치",
"카멜레온",
)
}
34 changes: 16 additions & 18 deletions src/main/kotlin/com/sbl/sulmun2yong/global/util/ResetSession.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading