Lacked
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
- Webhook cannot be deleted
After the webhook has been deleted, it can no longer be seen on the page. However, it has been observed that the appwrite-worker-webhook container is still gen...
- Webhook signatures
Hi, can someone help me with webhook signature validation in node js?
- Mistakenly rejected and Closed PR of hac...
Hello i have submitted a project called as Virtual -Labs for hackathon but the PR has been rejected and closed stating i have not used any of the appwrite servi...