From 7d648ac34ead318fbff60c196030aa05d040b38f Mon Sep 17 00:00:00 2001 From: nykoh2001 Date: Fri, 31 May 2024 15:13:23 +0900 Subject: [PATCH] [CHORE] #11 bearer prefix --- .../java/org/sopt/practice/common/jwt/JwtTokenProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seminar/week3/practice/src/main/java/org/sopt/practice/common/jwt/JwtTokenProvider.java b/seminar/week3/practice/src/main/java/org/sopt/practice/common/jwt/JwtTokenProvider.java index b22c84d..07882c0 100644 --- a/seminar/week3/practice/src/main/java/org/sopt/practice/common/jwt/JwtTokenProvider.java +++ b/seminar/week3/practice/src/main/java/org/sopt/practice/common/jwt/JwtTokenProvider.java @@ -19,6 +19,7 @@ @RequiredArgsConstructor public class JwtTokenProvider { private static final String USER_ID = "userId"; + private static final String BEARER_PREFIX = "Bearer "; private static final Long ACCESS_TOKEN_EXPIRATION_TIME = 24 * 60 * 60 * 1000L * 7; private static final Long REFRESH_TOKEN_EXPIRATION_TIME = 24 * 60 * 60 * 1000L * 14; @@ -58,7 +59,7 @@ public String generateAccessToken(Authentication authentication, Long tokenExpir claims.put(USER_ID, authentication.getPrincipal()); - return Jwts.builder() + return BEARER_PREFIX + Jwts.builder() .setHeaderParam(Header.TYPE, Header.JWT_TYPE) // Header .setClaims(claims) // Claim .signWith(getSigningKey()) // Signature @@ -71,7 +72,7 @@ public String generateRefreshToken(Long tokenExpirationTime) { .setIssuedAt(now) .setExpiration(new Date(now.getTime() + tokenExpirationTime)); // 만료 시간 - return Jwts.builder() + return BEARER_PREFIX + Jwts.builder() .setClaims(claims) .signWith(getSigningKey()) .compact();