Skip to main content

Module api_key

Module api_key 

Source
Expand description

API key authentication.

Provides static (env-based) and database-backed API key authentication. When an X-API-Key header (or configured header) is present, the key is hashed and looked up against configured storage. A valid key produces a SecurityContext; a missing key falls through to JWT authentication.

§Security

  • Keys are never stored or compared in plaintext — only SHA-256 hashes.
  • Comparison uses constant-time equality (subtle::ConstantTimeEq) to prevent timing side-channels.
  • Revoked keys (with revoked_at set) are rejected.

Structs§

ApiKeyAuthenticator
API key authenticator.
ApiKeyConfig
API key configuration embedded in the compiled schema.
StaticApiKeyConfig
A single static API key entry from configuration.

Enums§

ApiKeyResult
API key authentication result.

Functions§

api_key_authenticator_from_schema
Build an ApiKeyAuthenticator from the compiled schema’s security.api_keys JSON.