Alert Authentication and Security
Validating Signatures from Leaf
Keeping your webhook secure is essential to ensure that only Leaf sends requests to your endpoint. To help with this, Leaf uses signatures to verify every request.
Here’s how it works:
Signatures and Secrets: Each webhook request is signed using HMAC with SHA-256. The secret key you set up during the alert’s configuration is used to generate the signature.
What You Should Do: Use the X-Leaf-Signature header in the request to verify the signature. This ensures the request is genuine and untampered. The digest added to the X-Leaf-Signature header is encoded in base 64.
Handling the Request Body: Always read the request body as raw bytes before verifying the signature. The signed content is a compact JSON string without extra line breaks or spaces (other than spaces after ":" and ",").
By following these steps, you’ll ensure that your application only processes requests sent by Leaf.
info
Here is an example on how to verify the request in your webhook:
- Python
- Java
The value alert_payload
corresponds to the payload of the alerts.
For example, if you need to authenticate a created field, the alert_payload
will be:
Webhooks and IP Addresses
Leaf uses a cloud architecture to provide services, and as such, does not have a fixed range of IP addresses that issue webhooks.
When designing your network architecture, you may wish to have one set of servers and a load balancer in a DMZ that receive webhook requests from Leaf, and then proxy those requests to your private network.