Skip to content

Add admin endpoint POST /api/admin/users/:id/impersonate with short-lived audited token #472

Description

@1nonlypiece

Add admin endpoint POST /api/admin/users/:id/impersonate with short-lived audited token

Description

Support teams need to reproduce user issues but src/routes/admin.ts has no impersonation flow, so debugging requires unsafe credential sharing. Add POST /api/admin/users/:id/impersonate that issues a 5-minute JWT containing impersonatorId and writes an audit log entry capturing reason text.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Restrict to admin role via src/middleware/rbac.ts
  • Embed impersonatorId claim and reject self-impersonation
  • Log to audit_logs with reason
  • Add src/tests/impersonation.test.ts
  • Update docs/ADMIN_USER_MANAGEMENT_API.md

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feat/admin-impersonation
  • Implement changes
    • Edit src/routes/admin.ts
    • Update auth middleware to honour impersonatorId
    • Add tests and docs
  • Test and commit
    • Run npm test
    • Include test output and notes

Example commit message

feat: audited admin impersonation tokens

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programapiREST APIbackendDisciplr API serversecuritySecurity / audit

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