格式修改
This commit is contained in:
+6
-2
@@ -1,5 +1,7 @@
|
||||
package com.baiyue.integration.security;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
import com.baiyue.common.core.api.ResultCode;
|
||||
import com.baiyue.common.core.exception.BizException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -10,9 +12,11 @@ import java.security.MessageDigest;
|
||||
|
||||
@Component
|
||||
public class InternalServiceTokenGuard {
|
||||
private final byte[] expectedToken;
|
||||
@Value("${baiyue.security.internal-service-token}") private String token;
|
||||
private byte[] expectedToken;
|
||||
|
||||
public InternalServiceTokenGuard(@Value("${baiyue.security.internal-service-token}") String token) {
|
||||
@PostConstruct
|
||||
void initializeToken() {
|
||||
if (token == null || token.getBytes(StandardCharsets.UTF_8).length < 32) {
|
||||
throw new IllegalStateException("INTERNAL_SERVICE_TOKEN 至少需要 32 字节");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user