GitHub webhook verification: HMAC-SHA256 over the raw body, delivered as X-Hub-Signature-256: sha256=<hex>. See https://docs.github.com/webhooks/using-webhooks/validating-webhook-deliveries.
Functions
verify-request
fn (request: Map): Bool
fn (request: Map, secret: Str): Bool
Verify a GitHub webhook request. Returns true if the request is
authentic. Uses the github.webhook.secret context variable by
default (failing when it is unset), or accepts an explicit secret —
an empty explicit secret never verifies.
Example
github-webhook
meta {webhook: {service: "github", path: "/github/webhook"}}
fn (request) {
if(not(::github::webhooks/verify-request(request)),
::hot::http/HttpResponse({status: 401, body: "invalid signature"}),
send("github:webhook", request.body))
}
Context Vars:
github.webhook.secret