Page MenuHomePhabricator

[keyserver] verify webhook event with webhook secret
ClosedPublic

Authored by will on Oct 20 2024, 10:03 PM.
Tags
None
Referenced Files
F3529158: D13756.id45412.diff
Tue, Dec 24, 3:50 PM
F3528781: D13756.id45551.diff
Tue, Dec 24, 10:19 AM
F3526251: D13756.id45489.diff
Mon, Dec 23, 9:15 PM
Unknown Object (File)
Sat, Dec 14, 3:13 AM
Unknown Object (File)
Sun, Dec 1, 8:05 AM
Unknown Object (File)
Thu, Nov 28, 11:19 PM
Unknown Object (File)
Thu, Nov 28, 9:22 PM
Unknown Object (File)
Thu, Nov 28, 3:52 AM
Subscribers

Details

Summary

This verifies the webhook event with X-Neynar-Signature and the webhook secret to verify it's coming from Neynar.

Depends on D13755

Test Plan

Tested by triggering a webhook event on warpcast and verifying that isValid was true.
Verified that a webhook event with a differing body resulted in isValid evaluating as false

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

will requested review of this revision.Oct 20 2024, 10:22 PM
ashoat added inline comments.
keyserver/src/responders/farcaster-webhook-responders.js
16 ↗(On Diff #45286)

Nit

20 ↗(On Diff #45286)

How about signature, to match naming below

34 ↗(On Diff #45286)

Nit: don't know if we need the isValid variable... I would just inline the check on line 35

You could probably even inline signature === hmac.digest('hex') directly, to be honest

This revision is now accepted and ready to land.Oct 21 2024, 8:57 AM
will marked 3 inline comments as done.Oct 28 2024, 1:52 PM
keyserver/src/responders/farcaster-webhook-responders.js
16 ↗(On Diff #45286)

Addressed in latest rebase

20 ↗(On Diff #45286)

Changed to signature

34 ↗(On Diff #45286)

I inlined it in the function but also introduced a isValidSignature