Purge execution data including logs, metrics and outputs on a schedule
Automatically purge Kestra execution data, logs, metrics and outputs older than one month on a daily schedule.
Authenticate inbound webhooks with constant-time HMAC-SHA256 checks, audit every attempt in KV, alert on forgeries, and persist verified payloads.
A webhook URL is an open door: anyone who learns the key can start executions, and an unverified payload is trusted data wearing a costume. This blueprint closes the door with the same mechanism GitHub, Stripe, and every serious sender use — an HMAC-SHA256 signature over the raw body, verified with hmac.compare_digest so even the comparison cannot leak through timing. Every attempt (valid or not) is recorded in the namespace KV store, forgeries trigger a Slack alert and a failed execution so they show up in monitoring, and verified payloads are persisted to internal storage with a URI output that downstream flows consume.
inbound_webhook trigger (io.kestra.plugin.core.trigger.Webhook) exposes a keyed URL and hands the raw payload to {{ trigger.body }} and the request headers to {{ trigger.headers }}.verify_signature (io.kestra.plugin.scripts.python.Script on the io.kestra.plugin.core.runner.Process runner) receives the headers map (lowercased for a case-insensitive lookup), the configured header name, the body, and the signing secret through the environment. It strips an optional sha256= prefix, recomputes HMAC-SHA256(secret, body) as lowercase hex, and compares with hmac.compare_digest — constant-time, never ==. It emits valid and a human-readable reason through Kestra's outputs protocol.record_attempt (io.kestra.plugin.core.kv.Set) writes the execution ID, timestamp, verdict, and reason to WEBHOOK_GATE_LAST_ATTEMPT, giving dashboards and other flows a single key to read.enforce_signature (io.kestra.plugin.core.flow.If) branches on the verdict. Rejected: alert_intrusion_attempt posts the reason to Slack and reject_request (io.kestra.plugin.core.execution.Fail) turns the execution red. Verified: persist_event (io.kestra.plugin.core.storage.Write) lands the payload as JSON in internal storage and exposes its URI.errors block alerts Slack only on genuine infrastructure failures, worded explicitly so an errored gate is never mistaken for a rejected request.payload_uri output ready for a downstream flow or subflow.The Kestra webhook trigger guards the URL; nothing in a bare receiver guards the payload. Kestra makes the check a versioned, testable flow step: the verification logic is plain Python in the execution logs, the accept/reject decision is a declarative If, rejections become failed executions your alerting already watches, and the KV audit plus storage hand-off wire the result into the rest of your orchestration. In a custom server this same logic hides in framework middleware with no history, no alerts, and no downstream lineage.
verify_signature to a Docker task runner.WEBHOOK_SIGNING_SECRET: shared signing secret; must match the sender's configuration byte for byte.SIGNED_WEBHOOK_KEY: key segment of the webhook URL — treat it as a secret, but do not rely on it alone.SLACK_WEBHOOK_URL: Slack incoming webhook URL.Add the three secrets to your Kestra namespace and make WEBHOOK_SIGNING_SECRET identical to the sender's secret.
Point the sender at /api/v1/{tenant}/executions/webhook/{namespace}/webhook-hmac-signature-validation-gate/{SIGNED_WEBHOOK_KEY}.
Test locally before wiring the sender — sign a body with OpenSSL and curl the endpoint:
BODY='{"event":"demo"}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "your-signing-secret" | awk '{print $NF}')
curl -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-H "X-Hub-Signature-256: sha256=$SIG" \
-d "$BODY"
Expect a successful execution with verified: true and a payload_uri; send the same body with a wrong signature and expect the Slack rejection alert and a failed execution with reason: signature mismatch.
Read the verdict any time with {{ kv('WEBHOOK_GATE_LAST_ATTEMPT') }}.
"<timestamp>.<body>" instead of the raw body and parse t=...,v1=... — the script change is three lines, and the timestamp then enables a replay window.now() and reject anything older than a tolerance input.persist_event with an io.kestra.plugin.core.http.Request forward, a Subflow call, or a queue publish — the verification half stays untouched.Switch task keyed on a path or header.