Skip to content

Commit

Permalink
Merge from "jiyun"
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyunio committed Oct 10, 2024
1 parent 92a467d commit 5547d2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/com/appcenter/BJJ/global/jwt/JwtProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class JwtProvider {
private final UserDetailsServiceImpl userDetailsService;
private final Key key;
public static final long validAccessTime = 2 * 365 * 24 * 60 * 60L; // 2년 (이후에 3달로 바꿀 예정)
public static final long validAccessTime = 2L * 365 * 24 * 60 * 60 * 1000; // 2년 (이후에 3달로 바꿀 예정)

public JwtProvider(@Value("${spring.jwt.secret}") String secretKey, UserDetailsServiceImpl userDetailsService) {
byte[] ketBytes = Decoders.BASE64.decode(secretKey);
Expand All @@ -40,12 +40,15 @@ public String generateToken(Authentication authentication, Long time) {
Member member = ((UserDetailsImpl) authentication.getPrincipal()).getMember();
long now = (new Date()).getTime();
log.info("JWTProvider.generateToken() - 사용자 : {}", member.getEmail());
return Jwts.builder()
String accessToken = Jwts.builder()
.setSubject(member.getProviderId())
.claim("auth", authorities)
.setIssuedAt(new Date())
.setExpiration(new Date(now + time))
.signWith(key)
.compact();
log.info("JWTProvider.generateToken() - 토큰 발급 완료 / 유효기간 : {}, 발급시간 : {}", parseClaims(accessToken).getExpiration(), parseClaims(accessToken).getIssuedAt());
return accessToken;
}

public Authentication getAuthentication(String accessToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
import io.jsonwebtoken.impl.DefaultJwtParser;

@Slf4j
@Service
Expand Down

0 comments on commit 5547d2a

Please sign in to comment.