Skip to content

feat(webhooks): add webhook signing secret rotation endpoint#310

Merged
Baskarayelu merged 3 commits into
CredenceOrg:mainfrom
FolushoJoseph:feature/webhook-secret-rotation-fresh
Apr 26, 2026
Merged

feat(webhooks): add webhook signing secret rotation endpoint#310
Baskarayelu merged 3 commits into
CredenceOrg:mainfrom
FolushoJoseph:feature/webhook-secret-rotation-fresh

Conversation

@FolushoJoseph
Copy link
Copy Markdown
Contributor

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-secret endpoint (admin-only) to rotate secrets.

Implemented atomic secret rotation with randomBytes(32), storing the old secret as previousSecret for 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, and previousSecretExpiresAt.

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

feat(webhooks): add secure secret rotation with grace period

AI and others added 2 commits April 26, 2026 10:56
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>
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 26, 2026

@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! 🚀

Learn more about application limits

@Baskarayelu Baskarayelu merged commit 761a7b4 into CredenceOrg:main Apr 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fresh 2026-04][Backend] API: backend endpoint to rotate webhook signing secrets (audited + safe rollout)

2 participants