Skip to content

Add API key authentication with scopes and rotation for service-to-service callers #458

Description

@thlpkee20-wq

Description

Service-to-service callers currently reuse user JWTs. Add a first-class API key system with scopes, expiration, rotation overlap window, and per-key rate limits.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Relevant code: src/middleware/auth.ts, src/db/repositories/
  • Keys must be stored hashed; only prefix exposed to admin views

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feat/api-keys
  • Implement changes
    • Add api_keys table with hashed secret and scopes
    • Add middleware accepting Authorization: ApiKey ...
    • Add admin CRUD with rotation overlap
  • Validate security and correctness assumptions

Test and commit

  • Run tests
    • npm test
  • Cover edge cases
    • Scope escalation attempt, rotation overlap, revoked key
  • Include test output and notes

Example commit message

feat: scoped API keys with rotation

Guidelines

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

Metadata

Metadata

Assignees

No one assigned

    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