Skip to content

feat: implement robust audit logging system for all admin actions (#495) - #558

Merged
Abdulazeem-code merged 2 commits into
Abdulazeem-code:mainfrom
kaizercodes:feat/admin-audit-logging
Aug 27, 2026
Merged

feat: implement robust audit logging system for all admin actions (#495)#558
Abdulazeem-code merged 2 commits into
Abdulazeem-code:mainfrom
kaizercodes:feat/admin-audit-logging

Conversation

@kaizercodes

Copy link
Copy Markdown
Contributor

Overview

Implements an immutable audit logging system for all admin actions. It introduces an AuditLog table in Prisma, an asynchronous Express middleware that intercepts mutating requests (POST, PUT, DELETE, PATCH), redacts sensitive data (passwords, tokens, keys, signatures), and captures request metadata (action, method, IP, user ID, status code).

Related Issue

Closes #495

Changes

Database Schema & Prisma Client

  • [MODIFY] stellar-payment-platform/prisma/schema.prisma
    • Add AuditLog model with indexing on createdAt, userId, and action.
  • [MODIFY] stellar-payment-platform/prismaClient.js
    • Support auditLog in fallback mock client for test environments.

Middleware & Redaction

  • [ADD] stellar-payment-platform/src/middleware/auditLog.js
    • Implement createAuditLogMiddleware and auditLogMiddleware to intercept mutating admin requests asynchronously on res.on('finish').
    • Deep redaction of sensitive credentials (password, secret, apiKey, token, signature, privateKey, seed, etc.).
    • Safe extraction of IP address and user/admin ID.

Admin Routes

  • [MODIFY] stellar-payment-platform/src/routes/v1/adminRoutes.js
    • Hook auditLogMiddleware to intercept all mutating requests under /admin.
    • Add GET /admin/audit-logs endpoint for admin audit log inspection.

Documentation & Tests

  • [MODIFY] README.md
    • Document the audit logging system, sensitive field redaction, and GET /admin/audit-logs endpoint.
  • [ADD] stellar-payment-platform/tests/audit-log.test.js
    • 12 unit and integration tests covering deep redaction, IP/user ID extraction, middleware interception, failure isolation, and GET /admin/audit-logs.

Verification Results

Test Suites: 27 passed, 27 total
Tests:       394 passed, 394 total
Snapshots:   0 total
Time:        9.229 s
Ran all test suites.
Acceptance Criteria Status
AuditLog table created ✅ Created AuditLog model in schema.prisma and generated Prisma client
Middleware captures all POST/PUT/DELETE admin requests auditLogMiddleware intercepts all mutating methods (POST, PUT, DELETE, PATCH)
Sensitive data (passwords) redacted from logs ✅ Deep recursive redaction of sensitive keys (password, apiKey, secret, token, etc.)

@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

@Kaizer4show is attempting to deploy a commit to the Abdulazeem's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@Kaizer4show 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

@Abdulazeem-code

Copy link
Copy Markdown
Owner

FIXED FAILED CHECKS

@Abdulazeem-code
Abdulazeem-code merged commit 7d4276c into Abdulazeem-code:main Aug 27, 2026
6 of 10 checks passed
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.

Implement a robust audit logging system for all admin actions

2 participants