Authenticate a KalamDB Application
Sign in with a local account or your identity provider, then pass that identity to SQL and live subscriptions. Keep administrative credentials out of browser and mobile bundles.
Try KalamDB local authentication
After first-time server setup, create a normal application user as an administrator. This password is a local example; choose your own for a real account:
In a Node.js development script, supply that user’s password through the environment:
Expect the effective user identity in the query result. For a browser, use a sign-in flow and a token provider instead of embedding this password in source code. See the TypeScript authentication guide, Rust authentication, or Dart authentication for refresh and lifecycle handling.
Connect an external provider: Dex example
KalamDB uses one configured external OpenID Connect issuer. Dex is a reproducible local example; Keycloak and other compatible OIDC providers use the same issuer/client configuration model.
The KalamDB repository contains a local Dex setup:
Merge these settings into the server’s server.toml, preserving its other configuration:
Restart the server. The repository’s Dex client permits the Admin UI callback http://127.0.0.1:2900/ui/oauth/callback and CLI browser callback http://127.0.0.1:8787/callback. Open the Admin UI and select Dex, or run:
The bundled local Dex test account is alice@example.org with password kalamdb123. These are development fixtures, not deployment credentials. See Dex setup for the full configuration and device-login options.
Pass the provider identity to your SDK
After your application’s OIDC login flow returns the trusted ID token:
getFreshIdToken() belongs to your identity-provider integration; it must return a valid, refreshed token rather than a hardcoded token. The issuer must match the server configuration and the audience must match its client/audience settings. Use HTTPS for deployed issuers, callbacks, and API endpoints.
KalamDB validates the token and maps the OIDC subject to the effective user. That identity determines USER-table isolation and CURRENT_USER in RLS policies. Do not grant every provisioned account an administrative role to work around an authorization error.
Check the complete flow
- Sign in as a normal user and query
CURRENT_USER. - Write and read that user’s data.
- Sign in as a second user and verify isolation.
- Open a live subscription with the same identity.
- Test token refresh and sign-out; stop old subscriptions when accounts change.
For another provider, replace the issuer, client ID, allowed callbacks, and audience with that provider’s values. KalamDB supports one external issuer per process; multiple tenants/providers require an intentional identity-broker design.
Next step
Protect shared data with row-level security →
Reference: OIDC configuration and issuer trust.