개발/Java
[Spring] JWT Provider
[ 설정파일 ] jwt: valid-time: 3600000 # 1시간 key: password [ Provider ] @Service public class JwtProvider { @Value("${jwt.valid-time}") private int tokenValidTime; @Value("${jwt.key}") private String secretKey public String createToken(String userId) { Claims claims = Jwts.claims(); claims.put("user", userId); claims.put("role", "USER"); String token = Jwts.builder() .setClaims(claims) .setIssuedAt(n..
2022. 6. 24. 15:12