Skip to content

Commit

Permalink
fix: 액세스 토큰에 만료 정보를 다시 포함
Browse files Browse the repository at this point in the history
  • Loading branch information
SJ70 committed Aug 14, 2024
1 parent d93db6c commit e094240
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/j9/bestmoments/jwt/JwtTokenProvider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.j9.bestmoments.jwt;

import com.j9.bestmoments.constants.TokenExpiration;
import com.j9.bestmoments.domain.Member;
import com.sun.security.auth.UserPrincipal;
import io.jsonwebtoken.Claims;
Expand All @@ -12,6 +13,7 @@
import io.jsonwebtoken.security.Keys;
import java.security.Key;
import java.util.Collections;
import java.util.Date;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -34,9 +36,13 @@ public JwtTokenProvider(@Value("${jwt.secret}") String secretKey) {
}

public String generateAccessToken(Member member) {
Date now = new Date();
Date accessTokenExpiresIn = new Date(now.getTime() + TokenExpiration.ACCESS_TOKEN * 60 * 1000);
return Jwts.builder()
.claim("id", member.getId())
.claim("role", member.getRole().getValue())
.setIssuedAt(now)
.setExpiration(accessTokenExpiresIn)
.signWith(key, SignatureAlgorithm.HS256)
.compact();
}
Expand Down

0 comments on commit e094240

Please sign in to comment.