pixano_inference.security
API-key authentication for the inference server.
Authentication is optional: if no keys are configured (PIXANO_INFERENCE_API_KEYS),
the dependency is a no-op and a warning is emitted once at startup. When keys are set,
every guarded route requires a matching key supplied as either an X-API-Key header or
an Authorization: Bearer <key> header. Comparison is constant-time.
make_api_key_dependency(settings)
Build a FastAPI dependency enforcing API-key auth for the given settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
ServerSettings
|
Server settings holding the accepted API keys. |
required |
Returns:
| Type | Description |
|---|---|
|
An async dependency callable. It is a no-op when no keys are configured. |
Source code in pixano_inference/security.py
warn_if_auth_disabled(settings, host)
Emit a startup warning when auth is off, escalating on a non-loopback bind.