| package com.example.g8backend.config; |
| |
| |
| import io.jsonwebtoken.security.Keys; |
| import org.springframework.context.annotation.Bean; |
| import org.springframework.context.annotation.Configuration; |
| import javax.crypto.SecretKey; |
| import java.nio.charset.StandardCharsets; |
| |
| @Configuration |
| public class JwtConfig { |
| private static final String SECRET_KEY = "this-is-a-very-long-256-bit-secret-key-for-JWT"; // |
| private static final long EXPIRATION_MS = 3600_000; // 1小时 |
| |
| @Bean |
| public SecretKey jwtSecretKey() { |
| return Keys.hmacShaKeyFor(SECRET_KEY.getBytes(StandardCharsets.UTF_8)); |
| } |
| |
| public long getExpirationMs() { |
| return EXPIRATION_MS; |
| } |
| } |
| |