Authentication Setup Guide
This guide covers how to configure authentication for kube-workspaces, using either an external OIDC provider or built-in local (username/password) accounts. The two methods can be enabled independently or together.
Overview
kube-workspaces supports two authentication methods:
-
OIDC (OpenID Connect) - federate to an external identity provider:
- Dex (bundled or external) - federated OIDC proxy supporting GitHub, GitLab, LDAP, SAML, and more
- Okta - enterprise identity provider
- Any OIDC-compliant provider - Google, Auth0, Keycloak, Azure AD, etc.
- Local auth - username/password accounts stored as Kubernetes Secrets, with no external dependency. A default admin user is created automatically the first time local auth is enabled.
Authentication is opt-in and disabled by default. When disabled, the system operates without auth (everyone has full access).
The manifests explicitly install AuthConfig/default with spec.enabled: false
for unauthenticated mode. A missing/unreadable configuration must not be used as
a way to disable authentication: the API returns 503 auth_unavailable if it
cannot resolve configuration. Authenticated overlays patch the same singleton.
Apply/adopt this manifest behavior before updating older auth-disabled installs
to an API with fail-closed configuration handling. Chart adoption is a separate
operator-coordinated change.
Authenticated users need a current, enabled User CR; OIDC auto-provisioning must succeed or the external identity must be explicitly bound to an existing account. Role and namespace changes apply to subsequent API requests rather than waiting for old token claims to expire. New credentials bind to the User UID; agent-backed execution requires these bound credentials and will require a fresh sign-in for legacy sessions.
Configure ALLOWED_ORIGINS (Helm api.allowedOrigins) with the exact trusted
frontend origins, including scheme/port. The API rejects untrusted WebSocket
origins and cookie-authenticated mutations without a trusted Origin. Native
bearer clients can omit Origin. Keep workspace-hosted applications on origins
that are not in this trusted browser list.
Architecture
- Session tokens are HMAC-SHA256 signed JWTs stored in a
kw-sessionhttpOnly cookie - The signing key is stored in a Kubernetes Secret, and is used for sessions regardless of which authentication method issued them
- Local user passwords are bcrypt-hashed and stored in a per-user Kubernetes
Secret (
kw-password-<digest>), owned by the persisted User UID and referenced from theUserCR. Existing legacy references remain readable during upgrade. - User state is stored in
UserCRDs (cluster-scoped) - Configuration is stored in an
AuthConfigCRD (singleton nameddefault)
Prerequisites
- kube-workspaces deployed (controller, API, frontend)
- CRDs installed (
kubectl apply --server-side -k deploy/kustomize/crds/) - For OIDC: an OIDC provider configured with a client ID and secret, and the API reachable at a stable URL for the OIDC callback
- For local auth: nothing extra — see Option 5 below
Using local and OIDC login for the same account
Local passwords and OIDC bindings are independent methods on one User. Adding a method retains the User’s name, UID, personal namespace, workspaces and grants. OIDC identity is the exact issuer URL and subject, not an email address. An equal email, including a verified email, never silently adopts an existing account. An unbound identity whose email collides with an existing account is rejected and requires explicit linking.
An administrator can link their own existing account:
- Sign in to the account you want to retain, using its local password or an existing UID-bound administrator session. Change a temporary password first.
- Enable/configure the OIDC provider under Admin → Authentication, keeping local passwords enabled if you want both methods available.
- Open Admin → Users and select Link my OIDC identity.
- Authenticate to the configured OIDC provider in the same browser. Keep the initiating platform session until the callback completes.
- The Users page displays OIDC linked. Subsequent OIDC and local logins use the original account, even if the provider’s email later changes.
The linking transaction expires after five minutes and is single-use. The API rechecks the same administrator session and User UID at callback; demotion, disablement or account replacement prevents linking. It verifies the provider’s signature/JWKS, issuer, audience/authorized party, expiry and nonce and uses S256 PKCE. The separate adoption workflow below covers existing unbound OIDC-only accounts. Administrators can remove a binding using Unlink OIDC on its User row. Removal requires another usable, enabled login method, retains the identity reservation’s ownership, and revokes credentials derived from the removed binding. Relinking the same identity does not reactivate old sessions or device tokens. Unlinking your current session’s method requires signing in again through a remaining method.
Administrator-authorized linking for another account
An administrator can explicitly authorize adoption without giving the user a temporary local password or changing their role:
- Sign in with a UID-bound administrator session, completing any required password change first.
- Open Admin → Users and select Authorize OIDC linking on the existing, enabled account. OIDC-only, local-only and already-linked accounts are supported.
- Share the generated invitation securely with that account’s owner. It is single-use and expires five minutes after authorization, including the time spent signing in to the provider. Merely opening its landing page does not consume it.
- The owner opens the invitation, selects Continue to identity provider, and signs in with the approved account email. The provider must supply that email as verified; a different or unverified email is rejected.
- After linking, sign in through ordinary SSO. Linking itself does not replace an existing browser session. Refresh the Users page to see OIDC linked.
Approval is bound to the exact existing User UID, email, provider, client and complete account specification at approval time. The API rechecks the approving administrator’s current session/authority and target account before starting and completing the provider round trip. Disabled, replaced or concurrently edited targets are rejected; issue a fresh invitation after reviewing the current account. Duplicate/case-variant account emails require operator resolution. Issuer/subject is learned only from the verified OIDC token, not from invitation input or an email-only login. Existing roles, grants, namespaces and workspaces are preserved. Existing methods are retained; an identity reserved for another UID cannot be reassigned by invitation.
The HTTP contract is POST /auth/oidc/adoptions with JSON
{"userName":"existing-user","userUID":"<exact-user-uid>"} and header
X-KW-Link-Intent: link-account-identity, authenticated as the administrator.
It returns a relative adoptionURL, approved email and Unix expiresAt.
Use the returned invitation in the browser; do not manually edit User bindings.
Older invitations using adopt-legacy-identity remain limited to unbound
OIDC-only accounts; they do not acquire the broader linking authority on upgrade.
Native-token and browser-session handoff codes also revalidate the current account and credential at redemption, not only when issued. A failed redemption consumes the code. They preserve the login method and credential revision, so a password reset or identity unlink also invalidates pending grants from that method.
Method-aware sessions, reset and upgrade behavior
Session and device credentials identify their login method (local or oidc),
User UID and credential revision. OIDC credentials also bind to an exact
issuer/subject and its durable reservation. API and proxy validate current
credential state on each new request without contacting the identity provider.
- Local password reset/change invalidates previously issued local sessions,
device tokens and pending handoff grants. A password change replaces the
caller’s local session; browser replacements stay in an HttpOnly cookie, and
Bearer-only callers receive the replacement
tokenin the JSON response. - Password changes made from an OIDC session preserve that OIDC session while invalidating the account’s old local credentials.
- A temporary local password restricts local sessions to identity inspection, password change and sign-out. Workspace/admin access, proxy requests and new device/browser grants are denied until the password has been changed. A valid OIDC session is not restricted solely because the account also has a temporary local password. The native client opens its password form before workspace access; CLI login refuses to persist a restricted credential.
- Unlinking rotates the retained reservation revision before removing the User binding. If persistence fails, existing credentials from that binding may be revoked even though removal failed; refresh account state before retrying. Other methods and the User UID/namespace remain intact.
-
/auth/configadvertises configured methods and enables native OIDC only when the provider is configured./auth/mereportsauthMethod,localPasswordEnabled,oidcLinked,canChangePasswordand the current session’smustChangePassword. Clients must use these account/session fields instead of treating an installation with OIDC as if every session used SSO.
Upgrade requires fresh sign-in: credentials issued before method provenance was introduced cannot be safely classified and are rejected, including old device tokens. Users and their workspace resources are retained; this is a credential transition, not account migration. Recreate any pending linking or adoption transaction after signing in again.
Coordinate API/proxy rollout and deploy the updated web/native clients. Both server components must enforce this contract before relying on method-specific revocation; old versions do not enforce these claims and may discard provenance when minting devices. Existing identity reservations need no destructive migration: an older reservation’s UID supplies its initial revision. New reservations and unlink operations use explicit random revisions. Hash/revision and temporary-password policy replacements are written atomically in the password Secret, with the User flag also able to tighten restrictions.
Established API bridges/watch SSE and proxy WebSocket/SSE connections periodically
revalidate current credentials (default 5 seconds, configurable with positive
Go duration KW_CREDENTIAL_REVALIDATION_INTERVAL). Confirmed revocation terminates
the stream; three consecutive verification failures also terminate it fail-closed.
Lookup and teardown latency add to the interval. API WebSockets close with 4001;
updated browser/native clients stop automatic retries and request sign-in. The
transparent proxy closes the transport and does not promise a 4001 close frame.
State is read from Kubernetes, allowing another replica to observe revocation.
Rolling back to older API/proxy code also rolls back enforcement; do not describe
a rollback as preserving revocation behavior.
Password credential migration and recovery ownership
New account creation, enabling local login, bootstrap and administrative resets use collision-resistant Secrets bound to the persisted User UID. The API/proxy reject owned credentials referenced by another UID. User creation first persists the account, then installs credentials; if interrupted, use Enable local password on that same account rather than deleting/recreating it.
Existing email-derived/custom Secret references remain readable. Migrate them
deliberately with Reset password, the reset API, or make reset-admin-password
[email protected]. This rotates the selected account to a fresh
UID-owned Secret and requires a password change. It preserves the User UID,
namespace, workspaces, grants and OIDC methods. The previous Secret is not changed
or deleted, so another legacy account sharing it keeps its own credential. A
self-service password change on shared material is refused until an administrator
performs this migration. Review the inventory before and after migrating each
account; retain old unowned Secrets until no User references them and rollback
needs are resolved. New UID-owned Secrets are garbage-collected with their User.
Unreferenced owned Secrets from a conflicted/failed operation may be removed after
checking references; never adopt them into a different User.
Back up Users and credential Secrets together. A reset revokes local credentials
when its reference update succeeds; a failed conditional User update leaves the
previous credential active and returns no password as a success. Retry after
refreshing account state. Do not restore an old User password reference merely to
roll back binaries: that would intentionally restore the old password. Older code
can read the standard passwordSecretRef, but lacks the new ownership checks.
Personal namespace ownership is stamped with kubeworkspaces.io/user-uid.
Existing controller-labelled namespaces can be upgraded only for the account
whose persisted status.personalNamespace, name and email agree. Unlabelled or
other-UID namespaces are not adopted, and cleanup never deletes an unclaimed or
other-UID namespace. Template changes preserve an existing personal namespace.
For a legacy mismatch, restore the original User/namespace metadata from backup
after verifying ownership; do not recreate a User or assign another account’s UID.
Upgrade and migration ordering
Install the updated User CRD with server-side apply before deploying the API
that persists spec.externalIdentities. Helm upgrades do not automatically
upgrade files in the chart’s crds/ directory. Both the User binding and the
API’s atomic identity-claim Secret must exist; manually adding a User field alone
does not make an identity usable.
The read-only administrator endpoint GET /admin/auth-identities/inventory
reports duplicate/case-variant emails, legacy slug collisions, shared/missing/
orphan password Secrets, malformed/duplicate bindings and incomplete claims. It
returns names/references, never password hashes or plaintext passwords. Review
this inventory before adopting legacy identities; this release does not perform
automatic legacy-email migration. Existing OIDC-only accounts without bindings
can use the controlled adoption workflow above; an email match alone will no
longer log them in. Retain a usable local administrator for the transition.
Identity reservations bind to a User UID and survive account deletion. A failed second write leaves an inert reservation that the same account can resume; recreating a User or reusing its email does not transfer the reservation. Back up Users, authentication Secrets and signing keys together. Rolling back the API to an email-based version also rolls back the binding enforcement; retain the additive CRD fields and do not use that rollback as an identity migration.
Authentication state, identity claims, device registrations and local passwords
use kube-workspaces-system, including installations in another release
namespace. Ensure that namespace exists and adopt the chart’s authenticated
cross-namespace RBAC (auth.enabled: true) before using these flows. Enabling
authentication solely through the UI does not install missing chart RBAC.
Option 1: Bundled Dex (Helm)
The Helm chart includes Dex as an optional sub-chart. This is the simplest setup.
1. Create values file
# values-auth.yaml
auth:
enabled: true
oidc:
issuerURL: "https://dex.workspaces.example.com"
clientID: "kube-workspaces"
clientSecret:
create: true
value: "a-strong-random-secret"
scopes: ["openid", "email", "profile", "groups"]
session:
signingKey:
create: true
# Leave value empty for auto-generation, or set explicitly:
# value: "my-32-char-signing-key-here!!!!"
personalNamespaces:
enabled: true
template: ""
registration:
autoProvision: true
defaultRole: "editor"
adminEmails:
- "[email protected]"
api:
externalHost: "workspaces.example.com"
dex:
enabled: true
config:
issuer: "https://dex.workspaces.example.com"
storage:
type: kubernetes
config:
inCluster: true
web:
http: 0.0.0.0:5556
staticClients:
- id: kube-workspaces
name: "Kube Workspaces"
secret: "a-strong-random-secret"
redirectURIs:
- "https://workspaces.example.com/auth/callback"
connectors:
- type: github
id: github
name: GitHub
config:
clientID: "$GITHUB_CLIENT_ID"
clientSecret: "$GITHUB_CLIENT_SECRET"
redirectURI: "https://dex.workspaces.example.com/callback"
orgs:
- name: your-org
ingress:
enabled: true
className: nginx
hosts:
- host: dex.workspaces.example.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: dex-tls
hosts:
- dex.workspaces.example.com
2. Install
helm dependency update deploy/helm/kube-workspaces/
helm install kube-workspaces deploy/helm/kube-workspaces/ \
--namespace kube-workspaces-system \
--create-namespace \
-f values-auth.yaml
3. Verify
# Check AuthConfig status
kubectl get authconfig default -o yaml
# Should show:
# status:
# enabled: true
# issuerReachable: true
# conditions:
# - type: Ready
# status: "True"
# reason: IssuerVerified
Stable signing keys for GitOps
All authentication methods need the same stable session-signing Secret. Preserve it through upgrades, restores and local/OIDC configuration changes. Intentional rotation invalidates existing credentials; do not generate a new value during each reconciliation.
Helm CLI installs can generate a key and use cluster lookup to preserve it on
upgrade. Offline renderers such as ArgoCD cannot rely on lookup: rendering with
create: true and no explicit value generates a different key each time. For
GitOps, provision a persistent Secret through your encrypted-secret or
external-secret controller and reference it:
auth:
enabled: true
session:
signingKey:
create: false
secretName: kube-workspaces-session
secretKey: signing-key
oidc:
clientSecret:
create: false
secretName: kube-workspaces-oidc
secretKey: client-secret
The OIDC Secret is needed only when OIDC is configured. Local-only deployments still need the signing Secret. Do not store plaintext keys in a values file or check them into Git. Configure dependency ordering so the Secrets exist before auth-enabled components start.
Namespace prerequisites
Secrets must be in the component deployment namespace, not in personal workspace
namespaces. For Helm, create them in the namespace passed to --namespace;
API and proxy resolve signing/OIDC Secrets in that namespace. Check rendered
references before applying.
Account identity reservations and local-password Secrets currently use the fixed
kube-workspaces-system namespace, even with a custom Helm release namespace.
Create that namespace first as well. The chart renders namespaced Roles and
RoleBindings there for the release’s API/controller and proxy ServiceAccounts;
the installer needs permission to create those RBAC objects. Do not relocate or
delete existing account/password Secrets when moving a release.
The supplied Kustomize overlays target kube-workspaces-system. A custom
Kustomize installation must also adapt component namespace environment values,
ServiceAccount/RoleBinding subjects and Secret creation commands; setting only a
Kustomize namespace transformer does not rewrite arbitrary environment values.
Use the Helm namespace option when no custom overlay is maintained.
Kustomize auth overlays never create signing or OIDC Secrets. Create them once before applying the overlay and retain them on subsequent applies. See the OIDC overlay prerequisites and local overlay prerequisites.
When upgrading an older GitOps installation whose overlay owned these Secrets,
retain the existing values and transfer Secret ownership to the chosen secret
manager before enabling pruning of the new overlay. Removing a Secret from Git
must not cause the reconciler to delete the live signing key. Plain
kubectl apply -k without pruning leaves existing Secrets in place.
Option 2: External Dex
If you already have Dex deployed separately, just configure the OIDC settings to point to it.
1. Create secrets
# Session signing key
kubectl create secret generic kube-workspaces-session \
--namespace kube-workspaces-system \
--from-literal=signing-key="$(openssl rand -base64 32)"
# OIDC client secret (must match what's configured in Dex)
kubectl create secret generic kube-workspaces-oidc \
--namespace kube-workspaces-system \
--from-literal=client-secret="your-dex-client-secret"
2. Create AuthConfig
apiVersion: kubeworkspaces.io/v1alpha1
kind: AuthConfig
metadata:
name: default
spec:
enabled: true
oidc:
issuerURL: "https://dex.your-cluster.example.com"
clientID: "kube-workspaces"
clientSecret:
name: "kube-workspaces-oidc"
key: "client-secret"
scopes: ["openid", "email", "profile", "groups"]
usernameClaim: "email"
groupsClaim: "groups"
session:
signingKey: