Project

General

Profile

JMWebhook signature verification example in Go?

Added by Jonas Mikkelsen 3 months ago

The documentation shows the algorithm but the example is in Python. Has anyone got a Go version that handles the timestamp tolerance correctly?


Replies (2)

TB RE: Webhook signature verification example in Go? - Added by Tomas Brandt 3 months ago

We use a 5-minute tolerance and compare with hmac.Equal rather than ==. The order of the signed payload matters: timestamp, a dot, then the raw body, before any parsing.

HT RE: Webhook signature verification example in Go? - Added by Hiro Tanabe 3 months ago

Worth saying explicitly: verify against the raw body. If your framework has already decoded and re-encoded the JSON, the signature will never match and you will lose an afternoon.

    (1-2/2)