Skip to content

Add compliance audit log export endpoint for regulatory reporting #271

Description

@robertocarlous

Summary

Financial platforms are subject to AML/KYC and data-residency regulations that require producing a verifiable, tamper-evident audit trail on demand. Currently, audit log data exists in the database but there is no export mechanism for regulators or internal compliance teams.

Proposed Solution

Add GET /api/admin/audit-log/export endpoint:

Query params: from, to (ISO 8601), userId (optional), eventType (optional), format=json|csv

Response fields per record:
eventId, occurredAt, userId, adminKeyId, eventType, ipAddress, userAgent, requestId (correlation ID), metadata (JSONB)

Tamper-evidence:

  • Each exported batch includes an HMAC-SHA256 digest of the full payload, signed with a dedicated AUDIT_EXPORT_SECRET
  • Recipients can verify the digest to confirm the export has not been modified

Access control:

  • Requires admin key with super scope
  • Every export request is itself logged to the audit log (who exported, what range)
  • Exports rate-limited to 5 per hour per admin key

Acceptance Criteria

  • Export endpoint returns JSON and CSV formats
  • HMAC digest included in response header X-Audit-Digest
  • Export action itself recorded in audit log
  • Date range enforced: max 90-day window per request
  • Integration test verifies digest integrity (tamper a record, assert digest mismatch)
  • AUDIT_EXPORT_SECRET documented in .env.example
  • Endpoint documented in docs/API_REFERENCE.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions