Verifying signatures
Check that a webhook delivery really came from Imploy.
Every request is signed with the webhook's signing secret, so your endpoint can confirm a delivery came from Imploy. To verify a delivery:
- Read the raw request body, without changing it.
- Build the string
event_id + "." + timestamp + "." + body, using the values ofX-Imploy-Event-Id,X-Imploy-Timestampand the body. - Compute an HMAC-SHA256 of that string with your signing secret.
- Compare the result, as hex, with the value after
sha256=inX-Imploy-Signature.
expected = "sha256=" + hmac_sha256_hex(secret, event_id + "." + timestamp + "." + raw_body)
valid = constant_equals(expected, header("X-Imploy-Signature"))
Keep the signing secret private. Anyone who has it can send requests that look like they come from Imploy.
You can reveal or rotate the signing secret on the webhook. Rotating changes what your endpoint must use straight away. See Managing webhooks.
Was this page helpful?