Authentication & Bootstrap
KalamDB now has one authentication surface with two modes:
- local username/password login controlled by
[auth.local] - one external OpenID Connect provider controlled by
[auth.oidc]
There is no active provider matrix anymore. Dex, Keycloak, Okta, Auth0, Entra ID, Google, Firebase, and similar services all fit the same single-provider OIDC slot as long as they expose standards-compliant discovery metadata.
Use this page for the practical rollout:
- bootstrap the server locally
- create the initial DBA and root credentials
- configure
[auth.oidc] - test Admin UI and CLI login
- optionally disable local password login after migration
For the full config matrix, see OIDC & Issuer Trust. For a local test IdP, use Dex.
1. Bootstrap The Server
Check whether the server still needs first-time setup:
When the response contains "needs_setup": true, create the initial DBA and root password:
Important behavior:
POST /v1/api/auth/setupis localhost-only unlessauth.allow_remote_setup = true- setup creates the initial local admin credentials; it does not return tokens
- if you plan to disable local auth later, do the bootstrap first while
[auth.local].enabled = true
2. Configure Local + OIDC Auth In server.toml
Start with a combined rollout so you keep a local admin escape hatch while validating OIDC:
Rules that matter:
- KalamDB supports one external OIDC provider per server process
auth.oidc.issuerandauth.oidc.client_idare required whenauth.oidc.enabled = trueauth.oidc.scopesmust includeopenidauth.jwt_trusted_issuersshould include bothkalamdband the external issuer
Equivalent environment overrides:
Boolean env vars accept true, 1, or yes (case-insensitive).
3. Discover Available Login Methods
The Admin UI and CLI discover auth capabilities from the same endpoint:
Typical response:
4. Admin UI Browser Login
For browser login, configure the IdP redirect URI to:
The Admin UI uses Authorization Code + PKCE:
- browser fetches
/v1/api/auth/login-options - browser redirects to the configured OIDC authorization endpoint
- the callback page posts the code and PKCE verifier to
/v1/api/auth/oidc/exchange-code - KalamDB verifies the provider response and returns KalamDB access and refresh tokens
5. CLI Login
Local username/password login
Browser OIDC login
For browser OIDC, register this redirect URI at the provider:
Device login without opening a browser callback
This uses direct provider device flow when the provider exposes a device authorization endpoint.
Brokered device login
Use brokered mode when the CLI host cannot reach the provider directly but can reach KalamDB.
Operational notes:
- successful interactive
kalam logincontinues directly into the SQL shell - non-interactive
kalam loginsaves credentials and exits --no-saveskips writing credentials to disk
6. Use KalamDB Tokens For API Calls
After local login or OIDC exchange, use the returned KalamDB access token on API calls:
Use /v1/api/auth/me to confirm the resolved identity:
7. Auto-Provisioning And Explicit OIDC Users
With auth.oidc.auto_provision = true and auth.oidc.default_role = "user", regular OIDC users authenticate as their OIDC sub without a persisted per-user row when no local row exists.
When you need an elevated role before first login, or when auto_provision = false, pre-create the OIDC user explicitly with issuer and subject:
For persisted OIDC users, the CREATE USER id must match the OIDC subject.
8. Disable Local Password Login After Migration
Once OIDC is proven and you still have a safe DBA path, you can disable local password login:
This disables local username/password login server-side. The Admin UI and CLI also learn that state through /v1/api/auth/login-options and should hide local login controls.
Related
The bridge issuer (e.g. kalamdb-keycloak-bridge) must appear in jwt_trusted_issuers.
8. Production Hardening
Before exposing KalamDB publicly:
- Set strong
auth.jwt_secret(orKALAMDB_JWT_SECRET). - Keep
auth.allow_remote_setup = false. - Set
auth.cookie_secure = truebehind HTTPS. - Configure
auth.jwt_trusted_issuerswhen using external IdPs. - Tune
rate_limit.max_auth_requests_per_ip_per_sec.
For full endpoint auth behavior, see HTTP API Reference.