Skip to main content

Module api_keys

Module api_keys 

Source
Expand description

API Key management — Personal Access Token (PAT) pattern.

API keys are long-lived credentials that can be exchanged for short-lived JWTs. This allows agents and external systems to authenticate without managing JWT expiry themselves.

§Flow

  1. User creates an API key via POST /api/uar/auth/keys (requires JWT)
  2. Raw key is shown once — caller must store it securely
  3. Caller sends POST /api/uar/auth/exchange with the raw key → receives a JWT
  4. JWT is used for subsequent requests (standard Bearer auth)
  5. Middleware also accepts raw API keys directly via X-API-Key header

Structs§

ApiKeyMetadata
Public metadata returned to callers (no hash).
ApiKeyRecord
Stored API key record (hash only — raw key is never persisted).
ApiKeyResponse
Response returned when a key is created (raw key shown once).
ApiKeyService
API key management service.
CreateKeyRequest
Request body for creating a new API key.
InMemoryApiKeyStorage
Thread-safe in-memory API key store (suitable for development / testing).

Traits§

ApiKeyStorage
Persistence abstraction for API key records.