Webhooks
Check the signature of a received webhook (Stripe, GitHub, Slack or a generic HMAC scheme) and compute signatures for webhooks you send. Typical uses: make sure a payment notification really comes from Stripe.
webhook verifywebhook verifywebhook signwebhook sign

webhook verify <scheme> <payload> <signature> <secret>


Description

    Check a signature with the default parameters: JSON {valid, scheme, error, timestamp, age_s, replay_protected}. For slack, the timestamp is required: use the next form

Parameters

    scheme:   stripe, github, slack or generic - String - required
    payload:   The raw body - String - required
    signature:   The value of the signature header - String - required
    secret:   The signing secret - String - required
admin
webhook verify "github" "Hello, World!" "sha256=757107ea0eb2509fc211221cce984b8a37570b6d7586c22c46f4379c8b043e17" "It's a Secret to Everybody"
mentdb
{"valid": true, "scheme": "github", "error": null, "timestamp": null, "age_s": null, "replay_protected": false}
A modified body
admin
webhook verify "github" "Hello, World?" "sha256=757107ea0eb2509fc211221cce984b8a37570b6d7586c22c46f4379c8b043e17" "It's a Secret to Everybody"
mentdb
{"valid": false, "scheme": "github", "error": "the signature does not match", "timestamp": null, "age_s": null, "replay_protected": false}

webhook verify <scheme> <payload> <signature> <secret> <json_params>


Description

    Check a signature with parameters: timestamp (slack: the X-Slack-Request-Timestamp header; generic: the signed time), tolerance_s (300), now (seconds, for tests), payload_base64, secret_base64; github: allow_sha1 (the old X-Hub-Signature); generic: algo (sha256, sha384, sha512, sha1), encoding (hex, base64, base64url), prefix (text before the signature), separator (. between timestamp and body), require_timestamp

Parameters

    scheme:   The scheme - String - required
    payload:   The raw body - String - required
    signature:   The signature - String - required
    secret:   The secret - String - required
    json_params:   The parameters - String - required
admin
webhook verify "slack" "token=xyzz0WbapA4vBCDEFasx0q6G&team_id=T1DC2JH3J&team_domain=testteamnow&channel_id=G8PSS9T3V&channel_name=foobar&user_id=U2CERLKJA&user_name=roadrunner&command=%2Fwebhook-collect&text=&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT1DC2JH3J%2F397700885554%2F96rGlfmibIGlgcZRskXaIFfN&trigger_id=398738663015.47445629121.803a0bc887a14d10d2c447fce8b6703c" "v0=a2114d57b48eac39b9ad189dd8316235a7b4a8d21a10bd27519666489c69b503" "8f742231b10e8888abcd99yyyzzz85a5" "{\"timestamp\": \"1531420618\", \"now\": 1531420700}"
mentdb
{"valid": true, "scheme": "slack", "error": null, "timestamp": 1531420618, "age_s": 82, "replay_protected": true}
Stripe: the signature comes from the stripe library
admin
webhook verify "stripe" "{\"id\": \"evt_1\"}" "t=1800000000,v1=fa287d09db229533c641fdbe3df40ae037fe366dd1107528ae24e1374656a4b3" "whsec_demo" "{\"now\": 1800000010}"
mentdb
{"valid": true, "scheme": "stripe", "error": null, "timestamp": 1800000000, "age_s": 10, "replay_protected": true}
Stripe, one hour later: refused as a replay
admin
webhook verify "stripe" "{\"id\": \"evt_1\"}" "t=1800000000,v1=fa287d09db229533c641fdbe3df40ae037fe366dd1107528ae24e1374656a4b3" "whsec_demo" "{\"now\": 1800003600}"
mentdb
{"valid": false, "scheme": "stripe", "error": "the timestamp is outside the tolerance of 300 s", "timestamp": 1800000000, "age_s": 3600, "replay_protected": true}
Generic, Base64 as Shopify
admin
webhook verify "generic" "abc" "NC5RnOCtbAOja5jus/HRMNtIE7nfTRFg7aSI1xLceO4=" "k" "{\"encoding\": \"base64\"}"
mentdb
{"valid": true, "scheme": "generic", "error": null, "timestamp": null, "age_s": null, "replay_protected": false}
Used in use cases (1 recipe)

    Security engineer › Check that a webhook really comes from Stripe
Often used with

    webhook sign

webhook sign <scheme> <payload> <secret>


Description

    Compute the value of the signature header, to test an endpoint or to send a webhook. stripe and slack use the current time

Parameters

    scheme:   The scheme - String - required
    payload:   The body - String - required
    secret:   The secret - String - required
admin
webhook sign "github" "Hello, World!" "It's a Secret to Everybody"
mentdb
sha256=757107ea0eb2509fc211221cce984b8a37570b6d7586c22c46f4379c8b043e17

webhook sign <scheme> <payload> <secret> <json_params>


Description

    Compute with parameters: timestamp; now (seconds, used as the timestamp only for stripe, slack or require_timestamp when timestamp is not given); payload_base64, secret_base64; generic: algo, encoding, prefix, separator, require_timestamp

Parameters

    scheme:   The scheme - String - required
    payload:   The body - String - required
    secret:   The secret - String - required
    json_params:   The parameters - String - required
admin
webhook sign "stripe" "{\"id\": \"evt_1\"}" "whsec_demo" "{\"timestamp\": 1800000000}"
mentdb
t=1800000000,v1=fa287d09db229533c641fdbe3df40ae037fe366dd1107528ae24e1374656a4b3
Generic with a timestamp
admin
webhook sign "generic" "abc" "k" "{\"timestamp\": \"1800000000\", \"prefix\": \"v1=\", \"algo\": \"sha512\"}"
mentdb
v1=e9695761de1c9e835ecf591f92ba582a09030bc6e2f3f9cb26e54b9641a75169beda955b4857bbce85883443f2e51c68197bf099ce90eab0b0915714b8c1d622
Used in use cases (1 recipe)

    Security engineer › Check that a webhook really comes from Stripe
Often used with

    webhook verify