fix(gitea-webhook): X-Gitea-Signature 為純 hex,無 sha256= 前綴
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 12m39s
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 12m39s
Gitea 送出的簽章 header 是純 hex digest,不含 "sha256=" 前綴。 修正驗證邏輯兼容兩種格式(sha256= 前綴自動去除,否則直接用)。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -169,10 +169,12 @@ async def verify_gitea_signature(
|
||||
logger.warning("gitea_signature_missing")
|
||||
raise GiteaSignatureError("Missing X-Gitea-Signature header")
|
||||
|
||||
if not x_gitea_signature.startswith("sha256="):
|
||||
raise GiteaSignatureError("Invalid signature format (expected sha256=...)")
|
||||
|
||||
provided_signature = x_gitea_signature[7:] # 移除 "sha256=" 前綴
|
||||
# Gitea 送出純 hex(無 "sha256=" 前綴),GitHub 才有前綴
|
||||
# 2026-04-05 ogt: 修正 Gitea 實際格式為純 hex
|
||||
if x_gitea_signature.startswith("sha256="):
|
||||
provided_signature = x_gitea_signature[7:]
|
||||
else:
|
||||
provided_signature = x_gitea_signature
|
||||
|
||||
body = await request.body()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user