feat(api-integration): add Nango webhook handling#3716
Merged
Conversation
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Deploy Preview for hyprnote canceled.
|
✅ Deploy Preview for hyprnote-storybook canceled.
|
…egration Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
…w; adapt webhook signature verification to nango API Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(api-integration): add Nango webhook endpoint
Summary
Adds a
POST /webhookendpoint tocrates/api-integrationfor receiving Nango auth webhooks. The endpoint verifies theX-Nango-Hmac-Sha256signature against a configured secret and deserializes the payload into the existinghypr_nango::ConnectWebhooktype.Changes:
webhook.rsroute with HMAC-SHA256 signature verificationnango_webhook_secret(requiredString) added toIntegrationConfigandEnvhmacandsha2added as workspace dependencies/webhookalongside existing/connect-sessionNote: The handler currently logs the webhook event and returns
{ "status": "ok" }— it does not persist theconnection_id. Persistence/callback logic will need to be added by the consumer.Review & Testing Checklist for Human
verify_signatureuses!=on hex strings instead ofhmac's built-inmac.verify()which does constant-time comparison. Evaluate whether this timing side-channel matters for your threat model.IntegrationConfig::new()defaultsnango_webhook_secrettoString::new()— if a caller forgets.with_webhook_secret(...), verification will silently use an empty secret. Consider whether the secret should be a required constructor parameter instead.ConnectWebhooktype drops fields — Nango sendssuccess,providerConfigKey,provider,authMode,environmentetc. in auth webhooks, but the currentConnectWebhookstruct inhypr_nangodoesn't capture these. serde will silently ignore them, but you may want these fields (especiallysuccessandproviderConfigKey) for production use.connection_id→end_user_idmapping, which the Nango docs say is the primary purpose of the webhook. Verify this is intentional scaffolding vs. an oversight.Notes
Link to Devin run: https://app.devin.ai/sessions/67e3cd84b2784186b83fda3739d5891c
Requested by: @yujonglee