测试gitea部署

This commit is contained in:
cuizhibin 2025-07-22 10:23:36 +08:00
parent b3d8e8dbbc
commit f82c9ceb32
1 changed files with 3 additions and 4 deletions

View File

@ -61,7 +61,7 @@ public class DeployController {
// 1. 签名校验
if (!validSignature(body, signature)) {
throw new RuntimeException("签名错误");
return ResponseEntity.status(403).body("签名验证失败");
}
// 2. 启动部署流程
@ -75,9 +75,8 @@ public class DeployController {
try {
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(webhookSecret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
byte[] hash = mac.doFinal(body);
String computed = "sha256=" + bytesToHex(hash);
return computed.equalsIgnoreCase(sigHeader);
String computed = bytesToHex(mac.doFinal(body));
return computed.equalsIgnoreCase(sigHeader); // 不区分大小写
} catch (Exception e) {
return false;
}