Skip to content

Commit 06e986a

Browse files
committed
refactor: 토큰 만료시간 재설정
1 parent afd2055 commit 06e986a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/java/com/example/log4u/common/oauth2/jwt/JwtAuthenticationFilter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ protected void doFilterInternal(
7272
log.info("필터에서 추출한 access: " + accessToken + "\n");
7373

7474

75-
// 토큰 만료 확인, 만료 시 다음 필터로 넘기지 않음(재발급 필요)
75+
// 토큰 만료 확인 , 만료 시 다음 필터로 넘기지 않음(재발급 필요)
7676
try {
7777
System.out.println("만료확인");
78-
jwtUtil.isExpired(accessToken);
7978
System.out.println("category : " + jwtUtil.getCategory(accessToken));
8079
System.out.println("userId : " + jwtUtil.getUserId(accessToken));
8180
System.out.println("role : " + jwtUtil.getRole(accessToken));
81+
jwtUtil.isExpired(accessToken);
8282
} catch (ExpiredJwtException e) {
83+
e.printStackTrace();
8384
PrintWriter writer = response.getWriter();
8485
writer.print("토큰이 만료되었습니다.");
8586
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);

src/main/java/com/example/log4u/common/oauth2/jwt/JwtUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public String createJwt(String category, Long userId, String role, Long expiredM
7777
.claim("userId", userId)
7878
.claim("role", role)
7979
.issuedAt(new Date(System.currentTimeMillis()))
80-
.expiration(new Date(System.currentTimeMillis() + expiredMs))
80+
.expiration(new Date(System.currentTimeMillis() + expiredMs*1000))
8181
.signWith(secretKey)
8282
.compact();
8383
}

0 commit comments

Comments
 (0)