From 61b48f9026221df1ab4e07fca983ac776fff014c Mon Sep 17 00:00:00 2001 From: Anna-Jin Date: Mon, 18 Jul 2022 21:56:31 +0900 Subject: [PATCH] =?UTF-8?q?#18=20[Update]=20jwt=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mpnp/baechelin/login/jwt/AuthToken.java | 23 ++++--------------- .../login/jwt/controller/TokenController.java | 2 +- ...izationRequestBasedOnCookieRepository.java | 2 +- .../service/CustomOAuth2UserService.java | 2 +- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/mpnp/baechelin/login/jwt/AuthToken.java b/src/main/java/com/mpnp/baechelin/login/jwt/AuthToken.java index 79cb7ab..c228475 100644 --- a/src/main/java/com/mpnp/baechelin/login/jwt/AuthToken.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/AuthToken.java @@ -60,24 +60,11 @@ public boolean tokenValidate() { // 토큰의 claims, payload 값 가져오기 public Claims getTokenClaims() { - try { - return Jwts.parserBuilder() - .setSigningKey(key) - .build() - .parseClaimsJws(token) - .getBody(); - } catch (SignatureException e) { - log.info("잘못된 JWT 서명입니다."); - } catch (MalformedJwtException e) { - log.info("유효하지 않은 구성의 JWT 토큰입니다."); - } catch (ExpiredJwtException e) { - log.info("만료된 JWT 토큰입니다."); - } catch (UnsupportedJwtException e) { - log.info("지원되지 않는 형식이나 구성의 JWT 토큰입니다."); - } catch (IllegalArgumentException e) { - log.info(e.toString().split(":")[1].trim()); - } - return null; + return Jwts.parserBuilder() + .setSigningKey(key) + .build() + .parseClaimsJws(token) + .getBody(); } // 만료된 토큰인지 확인하는 용도 diff --git a/src/main/java/com/mpnp/baechelin/login/jwt/controller/TokenController.java b/src/main/java/com/mpnp/baechelin/login/jwt/controller/TokenController.java index 9dbe4ae..d31859b 100644 --- a/src/main/java/com/mpnp/baechelin/login/jwt/controller/TokenController.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/controller/TokenController.java @@ -20,7 +20,7 @@ public class TokenController { @ApiOperation(value = "Access Token 만료 시 Refresh Token을 이용하여 재발급 받는 메소드") @GetMapping("/refresh") - public AuthResponse refreshToken (HttpServletRequest request, HttpServletResponse response) { + public AuthResponse refreshToken (HttpServletRequest request, HttpServletResponse response) { return tokenService.refreshToken(request, response); } } diff --git a/src/main/java/com/mpnp/baechelin/login/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java b/src/main/java/com/mpnp/baechelin/login/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java index 56034bf..6fd882b 100644 --- a/src/main/java/com/mpnp/baechelin/login/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java @@ -9,7 +9,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -// refresh 토큰을 쿠기에 저장하기 위해 사용하는 repository +// refresh 토큰을 쿠키에 저장하기 위해 사용하는 repository public class OAuth2AuthorizationRequestBasedOnCookieRepository implements AuthorizationRequestRepository { public final static String OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME = "oauth2_auth_request"; diff --git a/src/main/java/com/mpnp/baechelin/login/oauth/service/CustomOAuth2UserService.java b/src/main/java/com/mpnp/baechelin/login/oauth/service/CustomOAuth2UserService.java index 311affa..f9179ca 100644 --- a/src/main/java/com/mpnp/baechelin/login/oauth/service/CustomOAuth2UserService.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/service/CustomOAuth2UserService.java @@ -61,7 +61,7 @@ private OAuth2User process(OAuth2UserRequest userRequest, OAuth2User user) { if (savedUser != null) { // DB에 유저 정보가 있을 때 if (providerType != savedUser.getProviderType()) { - throw new OAuthProviderMissMatchException(ErrorCode.ALREADY_LOGIN_ACCOUNT.getCode() + "=" + providerType); + throw new OAuthProviderMissMatchException(ErrorCode.ALREADY_LOGIN_ACCOUNT.getCode() + "," + providerType); } updateUser(savedUser, userInfo); } else {