From d39385a71fb4ddba901d2fb1c28c964241a27e8c Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Nov 2024 16:45:14 +0900 Subject: [PATCH 1/2] =?UTF-8?q?#580=20[feat]=20=EB=A6=AC=ED=94=84=EB=A0=88?= =?UTF-8?q?=EC=8B=9C=20=ED=86=A0=ED=81=B0=20=EB=A7=8C=EB=A3=8C=EC=8B=9C=20?= =?UTF-8?q?500=20=EC=97=90=EB=9F=AC=20=EC=95=84=EB=8B=8C=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=ED=83=80=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mile/common/auth/JwtTokenProvider.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module-api/src/main/java/com/mile/common/auth/JwtTokenProvider.java b/module-api/src/main/java/com/mile/common/auth/JwtTokenProvider.java index bc43a43b..535ee64f 100644 --- a/module-api/src/main/java/com/mile/common/auth/JwtTokenProvider.java +++ b/module-api/src/main/java/com/mile/common/auth/JwtTokenProvider.java @@ -123,6 +123,10 @@ public HashMap getJoinedRoleFromHeader(final String token) } public HashMap getJoinedRoleFromJwt(final String token) { + + if(!validateToken(token).equals(JwtValidationType.VALID_JWT)) { + throw new UnauthorizedException(ErrorMessage.TOKEN_INCORRECT_ERROR); + } Claims claims = getBody(token); Object joinedRole = claims.get(JOINED_ROLE); HashMap roleMap = objectMapper.convertValue(joinedRole, new TypeReference>() {}); From 9cd12fe1dcc5443e4aa75f3ed071280e94c216f7 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Nov 2024 16:55:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?#580=20[feat]=20AuthFacade=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC=20=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mile/common/auth/JwtTokenProvider.java | 4 ---- .../java/com/mile/controller/user/facade/AuthFacade.java | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/module-api/src/main/java/com/mile/common/auth/JwtTokenProvider.java b/module-api/src/main/java/com/mile/common/auth/JwtTokenProvider.java index 535ee64f..bc43a43b 100644 --- a/module-api/src/main/java/com/mile/common/auth/JwtTokenProvider.java +++ b/module-api/src/main/java/com/mile/common/auth/JwtTokenProvider.java @@ -123,10 +123,6 @@ public HashMap getJoinedRoleFromHeader(final String token) } public HashMap getJoinedRoleFromJwt(final String token) { - - if(!validateToken(token).equals(JwtValidationType.VALID_JWT)) { - throw new UnauthorizedException(ErrorMessage.TOKEN_INCORRECT_ERROR); - } Claims claims = getBody(token); Object joinedRole = claims.get(JOINED_ROLE); HashMap roleMap = objectMapper.convertValue(joinedRole, new TypeReference>() {}); diff --git a/module-api/src/main/java/com/mile/controller/user/facade/AuthFacade.java b/module-api/src/main/java/com/mile/controller/user/facade/AuthFacade.java index bcdfe959..f994710a 100644 --- a/module-api/src/main/java/com/mile/controller/user/facade/AuthFacade.java +++ b/module-api/src/main/java/com/mile/controller/user/facade/AuthFacade.java @@ -4,7 +4,9 @@ import com.mile.client.SocialType; import com.mile.client.dto.UserLoginRequest; import com.mile.common.auth.JwtTokenProvider; -import com.mile.writername.domain.MoimRole; +import com.mile.common.auth.JwtValidationType; +import com.mile.exception.message.ErrorMessage; +import com.mile.exception.model.UnauthorizedException; import com.mile.jwt.service.TokenService; import com.mile.moim.service.dto.response.MoimListOfUserResponse; import com.mile.strategy.LoginStrategyManager; @@ -34,6 +36,10 @@ public AccessTokenGetSuccess refreshToken( final String refreshToken ) { final Long userId = tokenService.findIdByRefreshToken(refreshToken); + + if(jwtTokenProvider.validateToken(refreshToken).equals(JwtValidationType.VALID_JWT)) { + throw new UnauthorizedException(ErrorMessage.TOKEN_INCORRECT_ERROR); + } final Map role = jwtTokenProvider.getJoinedRoleFromJwt(refreshToken); return AccessTokenGetSuccess.of(