Skip to content

Commit

Permalink
feat: 토큰 생성, 검증, 조회 구현
Browse files Browse the repository at this point in the history
- JWT 생성 구현
- Claims(Payload), 검증, 조회 미구현

resolve : #27
  • Loading branch information
BinarySstar committed Jan 6, 2025
1 parent 5e9695e commit 650223c
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package univ.goormthon.kongju.global.jwt.provider;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import javax.crypto.SecretKey;
import java.util.Date;

@Component
public class JwtProvider {

private final SecretKey key = Jwts.SIG.HS256.key().build();
private final long validityInMilliseconds = 1000 * 60 * 60; // 1시간

public String generateToken(Authentication authentication) {
String email = authentication.getName();

return Jwts.builder()
.subject(email)
.signWith(key)
.issuedAt(new Date())
.expiration(new Date(new Date().getTime() + validityInMilliseconds))
.compact();
}

public Claims getClaims(String token) {
}

public boolean validateToken(String token) {
}

public Authentication getAuthentication(String token) {
}


}

0 comments on commit 650223c

Please sign in to comment.