Zoho Sign offers you an option to secure your webhooks by using HMAC-SHA 256 (Hash-Based Message Authentication Codes with SHA 256), an industry standard hashing mechanism to ensure the authenticity and integrity of the webhook is intact. Securing a webhook with HMAC will help check:
- If the webhook request has been sent from Zoho Sign (The secret key must be known only to Zoho Sign and the receiving application).
- If the webhook content has been tampered with along the way (integrity).
How does webhook security work in Zoho Sign?
When a webhook is sent from Zoho Sign, a HMAC signature will be included in the request headers with the name X-ZS-WEBHOOK-SIGNATURE. Upon receiving the webhook request, the receiving application will generate a HMAC signature using the same secret key and compare the results with the value present in the request header. If the value matches, the data is legitimate; otherwise, the data has been tampered with.
Generating a HMAC signature
Zoho Sign calculates the signature of the webhook payload using the HMAC-SHA256 algorithm, and the result is sent in base64 format in the request header. Here is the explanation with sample data:
|
payload
|
{{"requests":{"request_name":"Test Name"},"notifications":{"operation_type":"RequestSigningSuccess"}}
|
|
secret_key
|
thisisthesamplekeyfortestingpurposes
|
|
base64encode(HMAC SHA-256(payload+secret_key))
|
drbSrM4H816RYKpZiRBLddUa0yHaTrwjtY04sIZFZus=
|
Here is an image of how this webhook request header (HMAC header) will look like: