Here's a code snippet
TypeScript
const signature = req.headers['x-appwrite-webhook-signature'];
if (!signature) {
return res.json({ error: "Bad signature request" });
}
// Create expected signature
const expectedSignature = crypto.createHmac('sha1', process.env.WEBHOOK_SIG_KEY)
.update(`${process.env.WEBHOOK_ENDPOINT}${JSON.stringify(payload)}`)
.digest('base64');
// Securely compare the signatures
if (!crypto.timingSafeEqual(Buffer.from(expectedSignature, 'base64'), Buffer.from(signature, 'base64')))
{
return res.json({ error: "Unauthorized" });
}...```
Is this enough to keep my webhook secure?
TL;DR
Code snippet provided shows how a developer is verifying the authenticity of a webhook message in Node.js by comparing signatures. It includes comparing expected and actual signatures using `crypto.timingSafeEqual`. This approach is secure, given proper implementation of `WEBHOOK_SIG_KEY`.Recommended threads
- How to send Webhooks to internal network
When saving the URL for sending Webhooks, Appwrite checks if it's a valid external domain name so entering internal IP address or docker hostnames won't save th...
- Can Sites deployments be limited to the ...
Hey all! I’m using Appwrite Cloud Sites with GitHub connected. Right now, Appwrite seems to build for every push and PR, not just for my production branch (main...
- Adding Custom Domain to self-hosted Appw...
Hi, i deployed Appwrite with Coolify and reaching it with appw.appname.de. What is working so far. I wanted to add another custom Domain to activate email verif...