This commit is contained in:
2026-08-05 16:26:10 +08:00
parent 06f7f9d2f2
commit 5ba9716e12
155 changed files with 2883 additions and 551 deletions
@@ -12,13 +12,19 @@ import java.security.MessageDigest;
@Component
public class InternalServiceTokenGuard {
private static final String INSECURE_PLACEHOLDER =
"change-me-to-an-internal-token-at-least-32-bytes-long";
@Value("${baiyue.security.internal-service-token}") private String token;
private byte[] expectedToken;
@PostConstruct
void initializeToken() {
if (token == null || token.getBytes(StandardCharsets.UTF_8).length < 32) {
throw new IllegalStateException("INTERNAL_SERVICE_TOKEN 至少需要 32 字节");
if (token == null
|| token.isBlank()
|| INSECURE_PLACEHOLDER.equals(token)
|| token.getBytes(StandardCharsets.UTF_8).length < 32) {
throw new IllegalStateException("INTERNAL_SERVICE_TOKEN 必须配置为至少 32 字节的安全令牌");
}
this.expectedToken = token.getBytes(StandardCharsets.UTF_8);
}
@@ -33,7 +33,7 @@ spring:
baiyue:
security:
internal-service-token: ${INTERNAL_SERVICE_TOKEN:change-me-to-an-internal-token-at-least-32-bytes-long}
internal-service-token: ${INTERNAL_SERVICE_TOKEN:}
integration:
baidu-ocr:
enabled: ${BAIDU_OCR_ENABLED:false}