feat(backend): audit logging for sensitive operations (#793) - #985
Merged
Smartdevs17 merged 1 commit intoSep 28, 2026
Conversation
Record authentication, payment, admin, identity, and compliance requests in the tamper-evident audit log so every sensitive action captures who did what, from where, and with what result. - Add sensitiveAudit middleware that classifies sensitive paths and logs timestamp, user, action, resource, IP, user agent, and outcome on response finish, treating aborted connections as failures - Add a first-class outcome field to AuditService entries (derived from the response status when not supplied) and include it in hashing and CSV export - Mount the middleware for all API routes and allow outcome in POST /audit/log - Fix audit resource derivation (payments instead of v1) and remove stale compiled auditService.js that shadowed the TypeScript source in tests - Document the behaviour and add unit tests Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@sandrawillow001-afk is attempting to deploy a commit to the smartdevs17's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@sandrawillow001-afk 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
Records authentication, payment, admin, identity, and compliance requests in the tamper-evident audit log, capturing timestamp, user, action, IP, and outcome for every sensitive operation.
Closes #793
Changes
sensitiveAuditmiddleware (backend/src/middleware/sensitiveAudit.ts):auth,payments,admin,identity,compliancefinish; aborted connections are recorded asfailureexcludePaths,actionMapper, anduserIdResolverAuditServicegains a first-classoutcomefield, derived from the response status when omitted, included in the entry hash and CSV export.POST /api/v1/audit/lognow acceptsoutcome.paymentsinstead ofv1) and removed a stale compiledauditService.jsthat shadowed the TypeScript source during tests.docs/security/audit-logging.md.Testing
cd backend && npx vitest run src/middleware/__tests__/audit.test.ts src/middleware/__tests__/sensitiveAudit.test.ts src/services/__tests__/auditService.test.ts→ 18 passed (16 new)npx eslinton changed files → 0 errors