Design issuance and validation of API keys for programmatic access: create keys with scopes, rotate with overlap window, revoke instantly, and rate limit per key. Never store raw keys; store only hashes and show secret once at creation.
Functional requirements
- Create key with name, scopes, and optional expiry
- Authenticate requests via key prefix lookup and hash verify
- Rotate key: issue new, mark old valid until cutoff
- Revoke key immediately and audit usage
Non-functional requirements
- Constant-time comparison for key material
- High throughput validation path with cache of allowed key metadata
- Compliance: who created and last used each key