Verifying that a webhook really comes from Leafy Energy
To prevent spoofing, the Leafy Energy demo signs every webhook request with an HMAC signature. You validate this signature before processing the payload.
Headers
X-Leafy-Signature: t=1710000000,v1=abcdef1234567890
tis a Unix timestamp.v1is the HMAC oftimestamp + "." + raw_bodyusing the shared secret.
Verification steps
- Read the
X-Leafy-Signatureheader. - Check that the timestamp is within an acceptable time window (for example 5 minutes).
- Compute the HMAC with your secret and compare it to the received hash.
In demo code samples you can implement this in Node.js, Python or any other language to clarify the pattern.
Comments
0 comments
Please sign in to leave a comment.