Skip to content

feat(backend): implement credential audit logging - #125

Merged
Josie123-Dev merged 1 commit into
GuardZero144:mainfrom
kris-nana:feat/50-credential-audit-logging
Jul 22, 2026
Merged

Josie123-Dev merged 1 commit into
GuardZero144:mainfrom
kris-nana:feat/50-credential-audit-logging

Conversation

@kris-nana

Copy link
Copy Markdown
Contributor

Closes #50

What changed

Adds a comprehensive, tamper-evident credential audit logging system to the backend (src/audit/).

  • AuditLog entity capturing timestamp, actor, operation type (issued/revoked/verified/updated/deleted/shared/accessed), target credential id, client IP, status and non-sensitive metadata.
  • Automatic logging via an AuditInterceptor + @Audit() decorator — credential handlers emit audit records with no per-handler boilerplate. Wired into the identity and verification controllers.
  • Integrity through HMAC hash-chaining: every entry commits to the previous entry's hash, so any post-hoc modification, insertion or deletion of a historical row is detectable via GET /audit-logs/verify.
  • Admin-only query interface (GET /audit-logs) with filtering (actor, operation type, status, target, date range) and pagination.
  • Export (GET /audit-logs/export?format=json|csv) for compliance review.
  • Retention — a background worker (AuditRetentionService) purges entries older than a configurable window; also triggerable via POST /audit-logs/retention/sweep.

Acceptance criteria

  • All credential operations are logged automatically
  • Log details are complete (actor, operation, target, IP, status, metadata)
  • Integrity is maintained and verifiable (HMAC hash-chaining + verify endpoint)
  • Query interface works (filtered, paginated, admin-only)
  • Retention is enforced (configurable background worker)

How to test

cd backend
npm test -- audit

Unit tests cover hash-chaining, tamper detection, filtered query, retention and export.

Configuration

New env vars (see backend/.env.example): AUDIT_HMAC_SECRET, ADMIN_WALLETS, AUDIT_RETENTION_DAYS, AUDIT_RETENTION_SWEEP_HOURS, AUDIT_RETENTION_ENABLED.

See backend/docs/AUDIT_LOGGING.md for full documentation.

Implement comprehensive, tamper-evident audit logging for all
credential operations (issuance, verification, revocation, updates,
deletion).

- AuditLog entity with HMAC hash-chaining so any post-hoc modification
  of a historical record is detectable
- AuditInterceptor + @Audit decorator for automatic, boilerplate-free
  capture around credential handlers; wired into the identity and
  verification controllers
- Admin-only query interface with filtering, pagination, integrity
  verification and JSON/CSV export
- Background retention worker enforcing a configurable retention policy
- Unit tests covering hash-chaining, tamper detection, filtered query,
  retention and export
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

@kris-nana is attempting to deploy a commit to the Josie's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sure-data Ready Ready Preview, Comment Jul 22, 2026 9:13pm

@Josie123-Dev
Josie123-Dev merged commit 46383c6 into GuardZero144:main Jul 22, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — e8c446bf Deployed Jul 22, 2026 by vercel[bot]
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.

[Hard] Implement credential audit logging

2 participants