Skip to content

webhook_signature ​

webhook_signature verifies the HMAC signature of webhook requests and rejects unsigned or tampered ones with 401 Unauthorized. The body is passed on unchanged.

yaml
server:
  http:
    middlewares:
      github_webhook:
        webhook_signature:
          preset: github
          secrets:
            - change-me-github-secret
      partner_webhook:
        webhook_signature:
          header: X-Signature
          prefix: "sha256="
          timestamp_header: X-Timestamp
          secrets:
            - change-me-partner-secret
FieldDefaultDescription
presetgenericgithub, stripe, slack, shopify, standard or generic.
secretsRequired. Signing secrets. Any of them may match, so a new secret can be added before the old one is removed.
secret_encodingrawraw, hex or base64.
headerfrom presetHeader holding the signature. Required for generic.
algorithmsha256sha1, sha256 or sha512.
encodinghexSignature encoding, hex or base64.
prefixText before the signature, e.g. sha256=.
timestamp_headerHeader with the request time in Unix seconds. It is signed as <timestamp>.<body>.
tolerance5mAccepted age of the timestamp, against replays.
max_body_size1MBLargest body read. Larger bodies get 413.
status_code401Status of rejected requests.

Presets ​

PresetHeaderSigned payload
githubX-Hub-Signature-256: sha256=<hex>body
shopifyX-Shopify-Hmac-Sha256: <base64>body
slackX-Slack-Signature: v0=<hex>, X-Slack-Request-Timestampv0:<timestamp>:<body>
stripeStripe-Signature: t=<timestamp>,v1=<hex><timestamp>.<body>
standardWebhook-Signature: v1,<base64>, Webhook-Id, Webhook-Timestamp<id>.<timestamp>.<body>

Standard Webhooks is also used by Svix and others. Its secrets are base64 with an optional whsec_ prefix. Fields set next to a preset override it.

Signatures are compared in constant time.