feat: add webhook secret rotation, prisma query scrubbing utilities, … - #1317
Merged
Merged
Conversation
…property SEO fields, and documentation
|
@Agbelomo 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.
Summary
Resolves multiple security, webhook reliability, and database migration issues across the backend:
VERBOSE_QUERY_LOGGING/ENABLE_QUERY_LOGGING).POST /webhooks/:id/rotate-secretendpoint allowing instant self-service invalidation and rotation of webhook signing secrets, recorded each rotation inActivityLog, and ensured old signatures are rejected.[1s, 5s, 15s, 60s, 300s]), addedX-Webhook-Idempotency-KeyandX-Webhook-Event-Idheaders to eliminate duplicate processing, added a daily cleanup cron for delivery logs, and documented semantics indocs/WEBHOOKS.md.prisma migrate deploy#1257): Reorganized 7 loose.sqlmigration files into proper Prisma migration folders (<name>/migration.sql), syncedschema.prismawith corresponding DDL (SEO fields and soft delete mappings onProperty), and replacedprisma db pushwithprisma migrate deployin CI.Changes by Issue
1. Database & Security (#1252)
scrubQuery(query: string): stringinsrc/database/prisma.service.tsto redact literals, emails, IPs, phone numbers, and$nplaceholders.VERBOSE_QUERY_LOGGING/ENABLE_QUERY_LOGGINGbefore emitting non-slow queries in non-production.src/database/prisma.service.spec.ts.2. Webhook Secret Rotation (#1255)
rotateSecret(id, userId)insrc/webhooks/webhooks.service.tsandPOST /webhooks/:id/rotate-secretinsrc/webhooks/webhooks.controller.ts.WEBHOOK_SECRET_ROTATEDaudit record inActivityLog.test/e2e/webhooks.e2e.spec.tsasserting self-service rotation, audit trail creation, and rejection of old signatures.3. Webhook Retry Backoff & Idempotency (#1256)
RETRY_DELAYS_MS([1000, 5000, 15000, 60000, 300000]) insrc/webhooks/webhooks.service.ts.X-Webhook-Idempotency-KeyandX-Webhook-Event-Idheaders in webhook delivery requests.retryFailedDeliveries.@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT)taskpruneOldDeliveryLogs(30)to purge expired logs.docs/WEBHOOKS.md.4. Prisma Migrations & CI Alignment (#1257)
.sqlfiles into valid migration directories:001_add_export_jobs/migration.sql20260330000000_add_seo_and_soft_delete_fields/migration.sql20260422000000_add_auth_security_foundation/migration.sql20260422170000_add_session_management/migration.sql20260422180000_add_trust_score/migration.sql20260423000000_add_api_key_permissions_and_usage/migration.sql20260424000000_add_document_features/migration.sql.sqlfiles from the root ofprisma/migrations/.Propertymodel inprisma/schema.prismawithmetaTitle,metaDescription,metaKeywords, and@map("is_deleted")..github/workflows/ci.ymltest database step fromnpx prisma db push --skip-generate --accept-data-losstonpx prisma migrate deploy.Closes Issues
prisma migrate deploy#1257