Skip to content

Commit

Permalink
refactor: log level 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
f1v3-dev committed Aug 7, 2024
1 parent e399409 commit 11738dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
String path = request.getRequestURI();
if(PatternMatchUtils.simpleMatch(SecurityConfig.WHITE_LIST, path)){
log.info("path: {} -> passed token filter", path);
log.debug("path: {} -> passed token filter", path);
filterChain.doFilter(request, response);
}
String token = parseBearerToken(request);
log.info("도착한 토큰: {}", token);
log.debug("도착한 토큰: {}", token);
if (token == null) { // Bearer 인증 방식이 아니거나 빈 값일 경우 진행하지 말고 다음 필터로 바로 넘김
filterChain.doFilter(request, response);
return;
}
String kakaoId;
try {
kakaoId = jwtProvider.validate(token);
log.info("검증된 카카오 ID: {}", kakaoId);
log.debug("검증된 카카오 ID: {}", kakaoId);
} catch (ExpiredJwtException e) {
log.error("엑세스 토큰이 만료됨", e);
throw new AccessTokenExpiredException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ public void logout(HttpServletRequest request, HttpServletResponse response, Aut
}
}

log.info("logout 시작");
log.debug("logout 시작");

if (refreshToken != null) {
log.info("logout refreshToken: {}", refreshToken);
log.debug("logout refreshToken: {}", refreshToken);

if (refreshTokenService.validateRefreshToken(refreshToken)) {
try {
refreshTokenService.deleteRefreshToken(refreshToken);
LocalDateTime expirationDate = LocalDateTime.now().plusWeeks(1);
blacklistService.blacklistToken(refreshToken, expirationDate);
log.info("logout 성공");
log.debug("logout 성공");
response.setStatus(HttpServletResponse.SC_OK);
} catch (Exception e) {
log.error("서버 에러", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dnd.jjakkak.domain.jwt.handler;

import com.dnd.jjakkak.domain.member.entity.Member;
import com.dnd.jjakkak.domain.jwt.provider.JwtProvider;
import com.dnd.jjakkak.domain.member.entity.Member;
import com.dnd.jjakkak.domain.member.service.RefreshTokenService;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
Expand Down Expand Up @@ -40,8 +40,8 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
String refreshToken = jwtProvider.createRefreshToken(kakaoId);
refreshTokenService.createRefreshToken(oauth2User.getMemberId(), refreshToken);

log.info("access token: " + accessToken);
log.info("refresh token: " + refreshToken);
log.debug("access token: " + accessToken);
log.debug("refresh token: " + refreshToken);

// Refresh Token 쿠키 설정
Cookie refreshTokenCookie = new Cookie("refresh_token", refreshToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ public class AuthController {
@GetMapping("/check-auth")
public ResponseEntity<?> checkAuth(HttpServletRequest request) {
String authorizationHeader = request.getHeader("Authorization");
log.info(authorizationHeader);
log.debug(authorizationHeader);
if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
String token = authorizationHeader.substring(7);
String subject = jwtProvider.validate(token);

if (subject != null && !subject.isEmpty()) {
log.info("isAuthenticated");
log.debug("isAuthenticated");
return ResponseEntity.ok().body(Collections.singletonMap("isAuthenticated", true));
}
}
log.info("isNotAuthenticated");
log.debug("isNotAuthenticated");
return ResponseEntity.ok().body(Collections.singletonMap("isAuthenticated", false));
}
}

0 comments on commit 11738dd

Please sign in to comment.