Simple API key authentication for service-to-service communication or controlled access scenarios.
The api-key-token module validates requests by comparing the bearer token
against a pre-configured API key.
authentication:
module: api-key-token
api_key_config:
api_key: "your-secret-api-key"| Option | Required | Description |
|---|---|---|
api_key |
Yes | The API key that clients must provide |
- Extracts bearer token from the
Authorizationheader - Compares token against configured
api_key - Rejects request if token doesn't match
- Uses same user ID and username handling as
noopmodule
Since API key authentication doesn't carry user identity information:
user_id: Defaults to00000000-0000-0000-0000-000or from query parameterusername: Fixed aslightspeed-user
curl http://localhost:8080/v1/query \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-secret-api-key" \
-d '{"query": "Hello"}'-
Use strong, random API keys: Generate keys with sufficient entropy
openssl rand -hex 32
-
Store keys securely: Use environment variables or secret management
authentication: module: api-key-token api_key_config: api_key: ${API_KEY} # From environment variable
-
Rotate keys regularly: Implement key rotation procedures
-
Use HTTPS: Always use TLS in production to protect keys in transit
- No user identity information (shared credential)
- Single key for all clients (no granular access control)
- No automatic key rotation
- Internal service-to-service communication
- Simple integrations with trusted clients
- Scenarios where OAuth2/OIDC is overkill
- User-facing applications (use
jwk-tokeninstead) - Multi-tenant environments (no user distinction)
- Scenarios requiring audit trails per user