package com.mailserver.config; import com.mailserver.util.JwtUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.nio.charset.StandardCharsets; @Configuration public class JwtConfig { /** JWT_SECRET from the environment, at least 32 bytes; no default — a known key would let anyone log in. */ @Bean public JwtUtils jwtUtils(@Value("${jwt.secret:}") String jwtSecret) { if (jwtSecret.getBytes(StandardCharsets.UTF_8).length < 32) { throw new IllegalStateException("jwt.secret (JWT_SECRET) must be set, at least 32 bytes"); } return new JwtUtils(jwtSecret); } }