优化
This commit is contained in:
@@ -25,7 +25,15 @@ public class InternalAccountController {
|
||||
private String configuredToken;
|
||||
private byte[] tokenBytes;
|
||||
|
||||
@PostConstruct void init() { tokenBytes = configuredToken.getBytes(StandardCharsets.UTF_8); }
|
||||
@PostConstruct
|
||||
void init() {
|
||||
byte[] configured = configuredToken == null
|
||||
? new byte[0] : configuredToken.getBytes(StandardCharsets.UTF_8);
|
||||
if (configured.length < 32) {
|
||||
throw new IllegalStateException("INTERNAL_SERVICE_TOKEN 至少需要 32 字节");
|
||||
}
|
||||
tokenBytes = configured;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ApiResponse<AccountSummary> create(@RequestHeader(value="X-Internal-Service-Token", required=false) String token,
|
||||
|
||||
Reference in New Issue
Block a user