Skip to content

Add audit trail logging for PII field access in profile and deployment routes #494

@temma02

Description

@temma02

Description

apps/backend/tests/compliance/verification.test.ts validates audit trail requirements but the actual routes do not emit audit log entries when PII fields (email, environment_variables) are read or written. This is a compliance gap.

Requirements and context

  • Must be secure, tested, and documented where applicable
  • Should stay reviewable and fit the current monorepo structure
  • Relevant files: apps/backend/tests/compliance/verification.test.ts, apps/backend/src/app/api/auth/profile/route.ts, apps/backend/src/app/api/deployments/[id]/route.ts, apps/backend/src/lib/api/logger.ts

Suggested execution

  • Create branch: issue-020-audit-trail-pii-field-access
  • Keep changes scoped to the issue and reference the task IDs in the PR

Implement changes

  • Extend createLogger to support an audit log level that writes to a separate sink
  • Emit audit entries on: profile read/write, environment_variables read, deployment delete
  • Include userId, action, resourceId, and timestamp in each entry

Test and commit

  • Add tests verifying audit entries are emitted for each PII-touching operation
  • Verify audit entries are not emitted for non-PII reads (e.g., template list)
  • Security note: audit log entries must never contain the PII values themselves

Example commit message

feat(audit): emit audit log entries for PII field access

Guidelines

  • Prefer small, reviewable PRs
  • Keep naming and data contracts consistent with the spec docs

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions