Authentication Overview
KalamDB has one authentication surface with two modes:
- local username/password login through
[auth.local] - one external OpenID Connect provider through
[auth.oidc]
The same API and SDK surfaces work for both:
POST /v1/api/auth/loginPOST /v1/api/auth/refreshGET /v1/api/auth/meGET /v1/api/auth/login-options- bearer auth for
/v1/api/sql, files, topics, and WebSocket traffic
Authentication Methods
| Method | Header | Description |
|---|---|---|
| Basic Auth | Authorization: Basic <base64(user:pass)> | Username + password login, usually exchanged for JWT |
| Bearer (Internal JWT) | Authorization: Bearer <token> | KalamDB-issued HS256 token |
| Bearer (External OIDC) | Authorization: Bearer <id-token> | Token from the configured trusted OIDC issuer |
All bearer tokens go through the same validation pipeline. KalamDB routes internal and external tokens automatically from the JWT algorithm and issuer.
Bearer Token Routing
KalamDB inspects the token before verification:
- Algorithm —
HS256→ internal shared-secret validation;RS256/ES256/…→ external OIDC flow. - Issuer (
iss) — must appear injwt_trusted_issuers; untrusted issuers are rejected before any network I/O. - JWKS — keys are fetched on first use and cached per-issuer; key rotation is handled automatically.
- Audience (
aud) — validated againstauth.oidc.audienceorauth.oidc.client_idwhen configured.
Single External OIDC Provider
KalamDB no longer uses a built-in provider enum or a provider matrix. The active external identity model is issuer-based:
Examples of issuers that fit this model:
- Dex
- Keycloak
- Okta
- Auth0
- Entra ID
- Firebase
The important point is that one KalamDB server process supports one configured external OIDC issuer.
Identity Mapping
External users use the OIDC sub claim directly as the KalamDB user_id. There is no provider code, username prefix, or generated hash ID in the active model.
The same subject value appears in SQL identity, system.users.user_id, and PG extension EXECUTE AS USER '<user_id>' workflows. The subject must be a valid KalamDB user ID: ASCII letters, digits, _, or -, up to 128 characters.
When KalamDB persists a local override or explicit OIDC user, it stores only this provider identity data:
Auto-Provision vs Explicit Users
When auth.oidc.auto_provision = true and auth.oidc.default_role = "user", regular external users authenticate as role user without a per-user row on the hot path.
KalamDB checks for an existing system.users row with user_id = sub first. That keeps explicit persisted OIDC users, deleted users, and same-ID local password users from being bypassed.
Elevated users still need explicit persisted overrides. Use this when a user must be service, dba, or system:
Browser And Device Login Surfaces
The Admin UI and CLI both discover auth capabilities from GET /v1/api/auth/login-options.
Current user-facing OIDC flows:
- Admin UI browser login through
/v1/api/auth/oidc/exchange-code - CLI browser login with
kalam login --oidc - CLI direct device login with
kalam login --oidc --no-browser - CLI brokered device login with
kalam login --oidc --no-browser --brokered
Role Management
Roles remain the same regardless of auth source:
user: normal app or tenant userservice: workers, automation, agentsdba: database administrationsystem: highest-privilege internal role
Supported Algorithms
| Algorithm | Supported |
|---|---|
| HS256 | ✅ Internal tokens only |
| RS256 | ✅ |
| RS384 | ✅ |
| RS512 | ✅ |
| PS256 | ✅ |
| PS384 | ✅ |
| PS512 | ✅ |
| ES256 | ✅ |
| ES384 | ✅ |
| ES512 | ❌ Not supported |