feat(autopilots): support header-auth webhooks#2897
Open
YOMXXX wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Reviewer note: this PR is ready for review. CI is green, merge state is clean, and there are no human review threads yet. Why it matters:
Suggested review focus:
Validation already run: focused webhook tests, full handler tests, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a non-secret webhook ingress URL for autopilot webhook triggers so integrations can keep credentials out of the path.
The existing token-in-path URL remains backward compatible. New
webhook_header_path/webhook_header_urlfields expose a trigger-ID path, and callers authenticate that path with eitherAuthorization: Bearer <webhook_token>,X-Multica-Webhook-Secret, or a valid HMAC signature.HMAC support uses
X-Multica-TimestampplusX-Multica-Signature: sha256=<hmac(timestamp + "." + raw_body, signing_secret)>with a five-minute skew window. Existing provider signatures such asX-Hub-Signature-256continue to work.Thinking path: issue #2883 asked to remove URL-embedded credentials from webhook use; the smallest compatible path is to keep existing token URLs stable, add a trigger-ID URL as the non-secret address, and reuse the existing token/signing-secret storage for header and HMAC authentication.
Risk: when a signing secret is configured, webhook delivery still requires a valid signature; static header auth is only accepted for trigger-ID paths where signature verification is not required. Delivery header persistence stores only presence flags for secret-bearing headers.
Related Issue
Closes #2883
Type of Change
Changes Made
server/internal/handler/autopilot_webhook.go: support token-path and trigger-ID credential lookup, header secret auth, timestamped Multica HMAC auth, and safe header persistence.server/internal/handler/autopilot.go: exposewebhook_header_pathandwebhook_header_urlfor webhook triggers.packages/core/types/autopilot.ts: add webhook header URL fields and signing/provider metadata to the trigger type.server/internal/handler/autopilot_webhook_test.go: cover Multica timestamped HMAC validation and stale timestamp rejection.server/internal/handler/autopilot_webhook_handler_test.go: cover trigger-ID path success with static header auth, rejection without header auth, and success with Multica HMAC.How to Test
cd server && go test ./internal/handler -run 'TestVerifyMulticaSignature|TestGenerateWebhookToken|TestNormalizeWebhookPayload'cd server && go test ./internal/handlercd server && go test ./...pnpm --filter @multica/core exec vitest run autopilots/webhook.test.tspnpm --filter @multica/core typecheckpnpm typecheckgit diff --checkmake testwas attempted but could not start the required local Postgres container because Docker daemon was unavailable:failed to connect to the docker API at unix:///Users/liguanchen/.docker/run/docker.sock.Checklist
apps/web/features/landing/i18n/) and relevant docs (apps/docs/content/docs/)apps/docs/content/docs/developers/conventions.zh.mdx(terminology, mixed-rule fortask/issue/skill)AI Disclosure
AI tool used: Codex
Prompt / approach: Used Codex to inspect the webhook trigger implementation, identify the credential-in-URL gap from issue #2883, implement a backward-compatible trigger-ID ingress path with header/HMAC authentication, and verify with focused handler tests plus repository typechecks.
Screenshots (optional)
N/A: API/backend behavior change.