Skip to content

feat(backend): Implement API key management for programmatic access #422

Description

@KuchiMercy

Description

api-key module exists with files. Complete implementation: scoped API key generation, rotation, revocation, and usage tracking.

Module: src/api-key/

Acceptance Criteria

  • ApiKey entity: id, userId, name, keyHash, keyPrefix (vlt_...), scopes, isActive, lastUsedAt, expiresAt
  • POST /api-keys — generate key with name, scopes, optional expiration
  • Return full key only once at creation
  • Scopes: read:escrows, write:escrows, read:analytics, admin
  • GET /api-keys (list with prefix only)
  • PATCH /api-keys/:id (update name/scopes/status)
  • DELETE /api-keys/:id (revoke)
  • POST /api-keys/:id/rotate (new key, deactivate old)
  • ApiKeyGuard middleware for X-API-Key header
  • Coexists with JWT auth
  • Bcrypt hashed storage
  • Async lastUsedAt tracking
  • Separate rate limiting (200 req/min)
  • Max 5 active keys per user
  • Auto-deactivate expired keys
  • Unit and E2E tests

Points: 150

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbackendenhancementNew feature or requestphase-3Sprint 5-6: Enhanced UX & SecuritysecuritySecurity improvements

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions