Expand description
Hashed product API-key store (G-039) for the operator server.
Mirrors the rusqlite pattern in crate::stel::ledger_store:
enum ApiKeyStore { Sqlite(..), Disabled }, idempotent migrate(), an
in-memory constructor for tests, and a poisoned-mutex-recovering lock so a
prior panic degrades instead of crashing the serve loop (FR-011 discipline).
§Security model (GATE-2 / FR-004 / SC-003)
- The raw secret is shown exactly once, at
ApiKeyStore::minttime, and is never persisted or returned again. Only a SHA-256 hash of the raw secret is stored. ApiKeyStore::verifyhashes the presented secret and compares (in constant time over the hex digest) against the stored hash of every active (non-revoked) key. A revoked key never verifies.ApiKeyStore::listreturns label / fingerprint / timestamps only — never the raw secret and never the full hash.
The raw secret is a high-entropy 256-bit random bearer token rendered as
sf_<64 hex>. Because it is random (not a human-chosen password) a plain
SHA-256 is appropriate; a slow password-KDF would add a dependency for no
security gain on a 256-bit random token (see research.md D3/D4).
Structs§
- ApiKey
Record - A persisted API-key record (never carries the raw secret).
- Minted
Key - The outcome of a successful
ApiKeyStore::mint: the record plus the raw secret shown exactly once. - Sqlite
ApiKey Store - SQLite-backed implementation.
Enums§
- ApiKey
Store - Hashed API-key store.
Disabledwhen the DB could not open.