Skip to content

feat/533 webhook secrets#6227

Open
jchui-wd wants to merge 2 commits intofeat/344-ambient-agents-webhooksfrom
feat/533-webhook-secrets
Open

feat/533 webhook secrets#6227
jchui-wd wants to merge 2 commits intofeat/344-ambient-agents-webhooksfrom
feat/533-webhook-secrets

Conversation

@jchui-wd
Copy link
Copy Markdown
Contributor

@jchui-wd jchui-wd commented Apr 16, 2026

Adds opt-in secret-based authentication for webhook-triggered agentflows.
Is Tied to #6217

Changes

Backend

  • New webhookSecret (hidden) and webhookSecretConfigured (boolean) columns on ChatFlow, with migrations for all 4 databases
  • POST /chatflows/:id/webhook-secret and DELETE /chatflows/:id/webhook-secret to generate/remove secrets
  • Signature verification runs before all other validation — supports HMAC-SHA256/SHA1 (GitHub, Stripe, Slack) and plain token (GitLab)

Start Node (v1.2)

  • When webhookTrigger is selected, now shows a generate secrets section with signature header, and signature type.

UI

  • webhookURL field renders the full trigger URL with a copy button
  • webhookSecret field manages generate/regenerate/remove with the plaintext shown only immediately after generation, then masked on reload
Test Videos Demo

WrongSignatureType-Fail.mp4

WrongSignatureType-Fail.mp4

PlainToken-WrongHeaderName-Fail.mp4

PlainToken-WrongHeaderName-Fail.mp4

PlainToken-working.mp4

PlainToken-working.mp4

No-Secret-401.mp4

No-Secret-401.mp4

HMAC-non256-working.mp4

HMAC-non256-working.mp4

HMAC-256-working.mp4

HMAC-256-working.mp4

Screenshots

Screenshot 2026-04-16 at 12 13 14 PM

Signature Type
Screenshot 2026-04-16 at 12 13 32 PM

No Secrets Generated
Screenshot 2026-04-16 at 12 13 23 PM

Tests
Screenshot 2026-04-16 at 12 24 22 PM

@jchui-wd jchui-wd changed the base branch from feat/344-ambient-agents-webhooks to feat/389-Headers-Query-Params-Methods-Validation-Etc April 16, 2026 01:12
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the webhook trigger functionality in Agentflows by adding support for HTTP method selection, Content-Type validation, and secure signature verification (HMAC-SHA256 and Plain Token). It introduces new configuration fields in the Start node, updates the database schema to store webhook secrets, and implements comprehensive validation logic in the backend. Additionally, the UI is updated to allow users to manage webhook secrets and access namespaced variables for headers, query parameters, and body content. Review feedback suggests refining the raw body storage type and improving type validation for form-encoded webhook payloads.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/server/src/index.ts (168)

medium

The buf provided by the verify callback of express.json and express.urlencoded is a Buffer. Casting it to a string using as unknown as string is misleading and potentially problematic if other parts of the application expect a string. Since verifyWebhookSignature correctly expects a Buffer, it is better to store it as such.

            ;(req as any).rawBody = buf

packages/server/src/services/webhook/index.ts (87-89)

medium

The strict typeof check will fail for number and boolean types when the incoming request is application/x-www-form-urlencoded, as all values in the request body are parsed as strings by default. Consider adding logic to handle numeric strings and boolean strings (e.g., "true", "false") to improve compatibility with various webhook senders.

        const typeMismatch = webhookBodyParams
            .filter((p) => {
                if (p.type == null || body?.[p.name] == null) return false
                const val = body[p.name]
                if (p.type === 'number') return isNaN(Number(val))
                if (p.type === 'boolean') return typeof val !== 'boolean' && val !== 'true' && val !== 'false'
                return typeof val !== p.type
            })
            .map((p) => p.name)

@jchui-wd jchui-wd marked this pull request as ready for review April 16, 2026 19:27
@jchui-wd jchui-wd changed the base branch from feat/389-Headers-Query-Params-Methods-Validation-Etc to feat/344-ambient-agents-webhooks April 17, 2026 21:11
@jchui-wd jchui-wd changed the base branch from feat/344-ambient-agents-webhooks to feat/389-Headers-Query-Params-Methods-Validation-Etc April 17, 2026 21:25
@jchui-wd jchui-wd changed the base branch from feat/389-Headers-Query-Params-Methods-Validation-Etc to feat/344-ambient-agents-webhooks April 17, 2026 21:25
…gger

Adds server-side webhook secret management (generate/clear/verify) and a
UI control in the Start node for configuring the secret, signature header,
and signature type (HMAC-SHA256 or plain token). Raw request body is now
captured before JSON parsing so HMAC signatures can be verified against the
original bytes. Migrations added for all four supported databases.
…validation

application/x-www-form-urlencoded payloads deliver all values as strings,
so the strict typeof check was incorrectly rejecting valid numeric ("42")
and boolean ("true"/"false") values. Updated the filter to coerce and
validate instead, with tests covering both JSON and form-encoded cases.
@jchui-wd jchui-wd force-pushed the feat/533-webhook-secrets branch from 6b46af4 to e1affad Compare April 17, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant