feat(webhooks): add webhook signing secret rotation endpoint#310
Merged
Baskarayelu merged 3 commits intoApr 26, 2026
Merged
Conversation
POST /api/webhooks/:webhookId/rotate-secret (admin-only) rotates the HMAC-SHA256 signing secret with safe-rollout semantics: the previous secret is preserved for 24 h so consumers can migrate without downtime. Every attempt — success or failure — is written to the audit log. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@FolushoJoseph Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
closes #271
Summary
This PR adds secure webhook secret rotation with a 24-hour grace period, allowing seamless client transitions without breaking integrations.
Changes Made
Added
POST /api/webhooks/:webhookId/rotate-secretendpoint (admin-only) to rotate secrets.Implemented atomic secret rotation with
randomBytes(32), storing the old secret aspreviousSecretfor 24 hours. During this window, both secrets are valid for verification, while all new deliveries use the new secret.Extended webhook config with
previousSecret,secretRotatedAt, andpreviousSecretExpiresAt.Added audit logging for all rotation attempts using
ROTATE_WEBHOOK_SECRET.Integrated route into app and added full test coverage (success, auth errors, grace window, audit logs).
Impact
Improves webhook security while ensuring zero downtime during secret rotation.
Commit Message