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
- 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...
- I need help with web hook set up for doc...
I have been getting the error below in my web hook log. URL: https://webhooks-emmanuel-samuel-agbedejobis-projects.vercel.app/api/kyc-webhook Method: POST St...
- Cannot connect to Github after migration...
I have migrated from 1.6.1 to 1.7.4. First moving to 1.6.2, then to 1.7.0 and after that to 1.7.4. I tried to deploy a new site but the connection to github wa...