From 43055b41310a92e94f539746cf3f727d2d2de164 Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 21 Dec 2023 11:30:50 +0900 Subject: [PATCH 1/2] =?UTF-8?q?log=20=ED=91=9C=EC=8B=9C=20=EC=97=86?= =?UTF-8?q?=EC=95=A0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/implementation/AuthServiceImpl.java | 15 --------------- .../gapple/weeingback/global/jwt/JwtProvider.java | 1 - 2 files changed, 16 deletions(-) diff --git a/src/main/java/com/gapple/weeingback/domain/auth/service/implementation/AuthServiceImpl.java b/src/main/java/com/gapple/weeingback/domain/auth/service/implementation/AuthServiceImpl.java index d60e1d0..408f1f2 100644 --- a/src/main/java/com/gapple/weeingback/domain/auth/service/implementation/AuthServiceImpl.java +++ b/src/main/java/com/gapple/weeingback/domain/auth/service/implementation/AuthServiceImpl.java @@ -103,8 +103,6 @@ public ResponseEntity refresh(String headerAuthorization, St } String refresh = jwtProvider.resolveToken(headerRefresh); String authorization = jwtProvider.resolveToken(headerAuthorization); - log.info("Access={}, Refresh={}", authorization, refresh); - log.info(SecurityContextHolder.getContext().getAuthentication().getAuthorities().toString()); boolean accessValidate = jwtProvider.validateToken(authorization); boolean refreshValidate = jwtProvider.validateToken(refresh); @@ -112,31 +110,23 @@ public ResponseEntity refresh(String headerAuthorization, St UUID savedId; if(refreshValidate){ Authentication refreshToken = jwtProvider.getAuthentication(refresh); - log.info("Authorities={}", refreshToken.getAuthorities()); savedId = UUID.fromString(refreshToken.getName()); } else savedId = UUID.fromString(SecurityContextHolder.getContext().getAuthentication().getName()); - log.info("savedId={}", savedId); ValueOperations stringValueOperations = stringRedisTemplate.opsForValue(); String token = stringValueOperations.get(savedId.toString()); - log.info("savedToken={}", token); - if(refresh.equals(token)){ if(!accessValidate && !refreshValidate){ throw new RuntimeException(); } else if(!accessValidate){ Member member = memberRepository.findMemberById(savedId); - log.info(member.getId().toString()); - String password = member.getPassword(); List roles = new ArrayList<>(); roles.add(AccessRole.valueOf(member.getRole())); - log.info(roles.toString()); - Authentication authentication = new UsernamePasswordAuthenticationToken(savedId.toString(), password, roles); @@ -146,19 +136,14 @@ public ResponseEntity refresh(String headerAuthorization, St return ResponseEntity.ok(new AuthLogoutResponse(newAccessToken, null, "ok")); } else if(!refreshValidate){ - log.info("authorization={}", authorization); Authentication authorizationToken = jwtProvider.getAuthentication(authorization); // 오류 발생지 - log.info("authorizationToken={}", authorizationToken); UUID id = UUID.fromString(authorizationToken.getName()); - log.info("id={}", id); String newRefresh = jwtProvider.generateRefreshToken(authorizationToken); - log.info("newRefresh={}",newRefresh); stringValueOperations.set(id.toString(), newRefresh); return ResponseEntity.ok(new AuthLogoutResponse(null, newRefresh, "ok")); } else { - log.info("ok"); return new ResponseEntity<>(HttpStatus.OK); } } else throw new RuntimeException(); diff --git a/src/main/java/com/gapple/weeingback/global/jwt/JwtProvider.java b/src/main/java/com/gapple/weeingback/global/jwt/JwtProvider.java index 9f635da..45643a5 100644 --- a/src/main/java/com/gapple/weeingback/global/jwt/JwtProvider.java +++ b/src/main/java/com/gapple/weeingback/global/jwt/JwtProvider.java @@ -63,7 +63,6 @@ public String resolveToken(String token) { } public Authentication getAuthentication(String accessToken) { - log.info("createAuthorityList={}", getRole(accessToken)); return new UsernamePasswordAuthenticationToken(getUsername(accessToken), "", createAuthorityList(getRole(accessToken))); } From 099ad235a2c1de0b11b4864db71a3c8d729aeb29 Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 21 Dec 2023 11:36:03 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=95=84=EC=9B=83=20?= =?UTF-8?q?=EB=A7=8C=EB=A3=8C=EB=90=9C=20=EA=B2=8C=20=EC=97=86=EC=9C=BC?= =?UTF-8?q?=EB=A9=B4=20=EB=B0=98=ED=95=9C=EB=90=98=EB=8A=94=20http=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/auth/service/implementation/AuthServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gapple/weeingback/domain/auth/service/implementation/AuthServiceImpl.java b/src/main/java/com/gapple/weeingback/domain/auth/service/implementation/AuthServiceImpl.java index 408f1f2..ccf6f50 100644 --- a/src/main/java/com/gapple/weeingback/domain/auth/service/implementation/AuthServiceImpl.java +++ b/src/main/java/com/gapple/weeingback/domain/auth/service/implementation/AuthServiceImpl.java @@ -144,7 +144,7 @@ public ResponseEntity refresh(String headerAuthorization, St return ResponseEntity.ok(new AuthLogoutResponse(null, newRefresh, "ok")); } else { - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().body(new AuthLogoutResponse(null, null, "ok")); } } else throw new RuntimeException(); }