From 657ba2af1484114171a2dd79bd83ebca130aca31 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 5 Jun 2024 01:09:46 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore=20:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=A0=9C=EA=B1=B0(#172)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bamyanggang/jwt/DefaultJwtRegistry.kt | 20 ------------------- .../kotlin/com/bamyanggang/jwt/JwtProvider.kt | 7 ++----- .../kotlin/com/bamyanggang/jwt/JwtRegistry.kt | 11 ---------- 3 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/DefaultJwtRegistry.kt delete mode 100644 Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/JwtRegistry.kt diff --git a/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/DefaultJwtRegistry.kt b/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/DefaultJwtRegistry.kt deleted file mode 100644 index f0ff501f..00000000 --- a/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/DefaultJwtRegistry.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.bamyanggang.jwt - -import org.springframework.stereotype.Component - -@Component -class DefaultJwtRegistry: JwtRegistry { - private val jwtMap = mutableMapOf() - - override fun upsert(keyValue: Pair) { - jwtMap[keyValue.first] = keyValue.second - } - - override fun isExists(value: String): Boolean { - return jwtMap.containsValue(value) - } - - override fun delete(value: String) { - jwtMap.entries.removeIf { it.value == value } - } -} \ No newline at end of file diff --git a/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/JwtProvider.kt b/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/JwtProvider.kt index 96211d92..50c06e40 100644 --- a/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/JwtProvider.kt +++ b/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/JwtProvider.kt @@ -7,8 +7,7 @@ import java.util.* @Component class JwtProvider( private val jwtProperties: JwtProperties, - private val jwtKeyGenerator: JwtKeyGenerator, - private val jwtRegistry: JwtRegistry + private val jwtKeyGenerator: JwtKeyGenerator ) { fun generateAccessToken(user: Claims.UserClaims): String { @@ -19,12 +18,10 @@ class JwtProvider( } fun generateRefreshToken(user: Claims.UserClaims): String { - val refreshToken = generateToken( + return generateToken( user.createPrivateClaims(TokenType.REFRESH_TOKEN), jwtProperties.refreshTokenExpirationTime ) - jwtRegistry.upsert(user.userId to refreshToken) - return refreshToken } fun generateRegistrationToken(registrationClaims: Claims.RegistrationClaims): String { diff --git a/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/JwtRegistry.kt b/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/JwtRegistry.kt deleted file mode 100644 index a3eb6fda..00000000 --- a/Support-Module/Jwt/src/main/kotlin/com/bamyanggang/jwt/JwtRegistry.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.bamyanggang.jwt - -interface JwtRegistry { - - fun upsert(keyValue: Pair) - - fun isExists(value: String): Boolean - - fun delete(value: String) - -} \ No newline at end of file From b4bfbded8371464d6c4667c2910f49cb22ebf80c Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 5 Jun 2024 01:10:27 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix=20:=20=EC=9E=AC=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=EC=8B=9C=20=ED=86=A0=ED=81=B0=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95(#1?= =?UTF-8?q?72)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domainmodule/domain/user/service/TokenAppender.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/user/service/TokenAppender.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/user/service/TokenAppender.kt index e3b47f02..bb4eb5c1 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/user/service/TokenAppender.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/user/service/TokenAppender.kt @@ -13,8 +13,8 @@ class TokenAppender ( ) { val existingToken = tokenRepository.findByUserId(userId) existingToken?.let { - it.update(userId = userId, refreshToken = refreshToken) - tokenRepository.save(it) + val updatedToken = it.update(userId = userId, refreshToken = refreshToken) + tokenRepository.save(updatedToken) } ?: Token.create( userId = userId, value = refreshToken From 1d8568fe89083e48ed4eda8b081a7b2b4087be4c Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 5 Jun 2024 01:10:59 +0900 Subject: [PATCH 3/4] =?UTF-8?q?chore=20:=20log=20yml=20=EC=82=AD=EC=A0=9C(?= =?UTF-8?q?#172)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api-Module/src/main/resources/application-log.yml | 4 ---- Api-Module/src/main/resources/application.yml | 1 - 2 files changed, 5 deletions(-) delete mode 100644 Api-Module/src/main/resources/application-log.yml diff --git a/Api-Module/src/main/resources/application-log.yml b/Api-Module/src/main/resources/application-log.yml deleted file mode 100644 index 9898e18d..00000000 --- a/Api-Module/src/main/resources/application-log.yml +++ /dev/null @@ -1,4 +0,0 @@ -logging: - level: - org.springframework.web: DEBUG - org.springframework.web.servlet.resource: DEBUG diff --git a/Api-Module/src/main/resources/application.yml b/Api-Module/src/main/resources/application.yml index aad244c2..f687b956 100644 --- a/Api-Module/src/main/resources/application.yml +++ b/Api-Module/src/main/resources/application.yml @@ -6,4 +6,3 @@ spring: include: - db - jwt - - log From 93fb37c565bcd8c0db6ef5af18a5c47b4a3a64f4 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 5 Jun 2024 01:40:57 +0900 Subject: [PATCH 4/4] =?UTF-8?q?test=20:=20TokenAppenderTest=20=EC=88=98?= =?UTF-8?q?=EC=A0=95(#172)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domainmodule/domain/user/service/TokenAppenderTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/user/service/TokenAppenderTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/user/service/TokenAppenderTest.kt index 9a642f09..d45e326f 100644 --- a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/user/service/TokenAppenderTest.kt +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/user/service/TokenAppenderTest.kt @@ -30,6 +30,7 @@ class TokenAppenderTest : BehaviorSpec({ Given("a user id and a refresh token, and the user has an existing token") { val mockToken = mockk(relaxed = true) every { mockTokenRepository.findByUserId(userId) } returns mockToken + every { mockToken.update(userId, refreshToken) } returns mockToken When("appendToken is called") { tokenAppender.appendToken(userId, refreshToken)