Configures SSO authentication and SCIM 2.0 provisioning for CockroachDB across four distinct layers — Cloud Console SSO (SAML/OIDC), DB Console SSO (OIDC), SQL/Cluster SSO (JWT or LDAP/AD), and SCIM 2.0 automated provisioning. Use when enabling centralized identity management, setting up SSO for compliance, or automating user lifecycle management.
84
81%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Risky
Do not use without reviewing
Configures Single Sign-On (SSO) and SCIM 2.0 provisioning for CockroachDB across four distinct layers:
ccloud auth login) — for Cloud Console SSO/SCIMVerify access:
ccloud auth whoamiBefore proceeding, determine which layers the user needs. Ask which of the following apply, then follow only the relevant Parts below.
Decision 1 — Cloud Console SSO:
Decision 2 — DB Console SSO:
Decision 3 — SQL/Cluster SSO method:
Decision 4 — SCIM 2.0 provisioning:
Before configuring anything, audit the current state of all four SSO layers.
Check SSO status in the Cloud Console UI: Organization Settings > Authentication. The ccloud CLI does not expose SSO configuration commands.
SHOW CLUSTER SETTING server.oidc_authentication.enabled;
SHOW CLUSTER SETTING server.oidc_authentication.provider_url;
SHOW CLUSTER SETTING server.oidc_authentication.client_id;SHOW CLUSTER SETTING server.jwt_authentication.enabled;
SHOW CLUSTER SETTING server.jwt_authentication.issuers.configuration;
SHOW CLUSTER SETTING server.jwt_authentication.jwks_auto_fetch.enabled;-- Check HBA rules for any ldap method entries
SHOW CLUSTER SETTING server.host_based_authentication.configuration;Look for lines containing ldap in the HBA output.
SHOW CLUSTER SETTING security.provisioning.jwt.enabled;
SHOW CLUSTER SETTING security.provisioning.ldap.enabled;Cloud Console SSO enables SAML or OIDC authentication for the CockroachDB Cloud web console, replacing password-based login.
Check SSO status in the Cloud Console UI (Organization Settings > Authentication). The ccloud CLI does not currently expose SSO configuration commands.
Follow this section if the user selected SAML in Decision 1.
email, firstName, lastNameSee configuration steps reference for IdP-specific SAML instructions (Okta, Azure AD).
Follow this section if the user selected OIDC in Decision 1.
https://accounts.google.com/.well-known/openid-configuration)openid, profile, emailSee configuration steps reference for IdP-specific OIDC instructions (Okta, Azure AD, Google Workspace).
After verifying SSO works:
This configures SSO for the DB Console web UI only, NOT for SQL client connections. SQL client SSO is configured separately in Part 3 (JWT) or Part 4 (LDAP/AD).
Prerequisite: Advanced or Enterprise plan required. DB Console SSO is not available on Standard or Basic plans.
DB Console SSO uses OIDC to authenticate users to the CockroachDB DB Console web interface.
SHOW CLUSTER SETTING server.oidc_authentication.enabled;
SHOW CLUSTER SETTING server.oidc_authentication.provider_url;
SHOW CLUSTER SETTING server.oidc_authentication.client_id;-- Enable OIDC authentication for the DB Console
SET CLUSTER SETTING server.oidc_authentication.enabled = true;
-- Set the OIDC provider URL (your IdP's discovery endpoint)
SET CLUSTER SETTING server.oidc_authentication.provider_url = 'https://your-idp.example.com';
-- Set the client ID registered in your IdP
SET CLUSTER SETTING server.oidc_authentication.client_id = '<client-id>';
-- Set the client secret
SET CLUSTER SETTING server.oidc_authentication.client_secret = '<client-secret>';
-- Configure the claim field used for username mapping
SET CLUSTER SETTING server.oidc_authentication.claim_json_key = 'email';
-- Configure the principal regex (extract username from claim)
SET CLUSTER SETTING server.oidc_authentication.principal_regex = '^([^@]+)';See configuration steps reference for IdP-specific DB Console SSO setup (Okta, Azure AD).
SQL/Cluster SSO uses JWT tokens from an IdP to authenticate SQL client connections. This is separate from DB Console SSO (Part 2) — it authenticates cockroach sql and application connections, not the web UI.
SHOW CLUSTER SETTING server.jwt_authentication.enabled;
SHOW CLUSTER SETTING server.jwt_authentication.issuers.configuration;
SHOW CLUSTER SETTING server.jwt_authentication.jwks_auto_fetch.enabled;-- Enable JWT authentication for SQL connections
SET CLUSTER SETTING server.jwt_authentication.enabled = true;
-- Configure the JWT issuer(s)
-- Format: JSON object with issuer URL and audience
SET CLUSTER SETTING server.jwt_authentication.issuers.configuration = '{
"issuers": [
{
"issuer": "https://your-idp.example.com",
"audience": "<client-id>"
}
]
}';
-- Enable automatic JWKS fetching (recommended)
SET CLUSTER SETTING server.jwt_authentication.jwks_auto_fetch.enabled = true;
-- Configure the claim used for SQL username mapping
SET CLUSTER SETTING server.jwt_authentication.claim = 'email';See configuration steps reference for IdP-specific JWT configuration (Okta, Azure AD, Google).
Map IdP identities (e.g., email addresses) to SQL usernames:
-- Map user@example.com -> user (strip domain)
SET CLUSTER SETTING server.identity_map.configuration = '
crdb /^(.*)@example\.com$ \1
';Auto-provision SQL users when they first authenticate via JWT:
SET CLUSTER SETTING security.provisioning.jwt.enabled = true;When enabled, a SQL user is automatically created for authenticated JWT users who do not yet have an account.
# Obtain a JWT token from your IdP (method varies by IdP)
# Then connect using the token as the password with JWT auth enabled
cockroach sql --url "postgresql://<username>@<cluster-host>:26257/defaultdb?sslmode=verify-full&options=--crdb:jwt_auth_enabled=true" --external-io-implicit-credentialsThe JWT token is passed as the password. The --crdb:jwt_auth_enabled=true connection option tells CockroachDB to treat the password as a JWT token.
-- Verify the connection
SELECT current_user();LDAP/AD authentication validates SQL credentials directly against an LDAP directory (Active Directory or OpenLDAP). Self-hosted only — not available on CockroachDB Cloud.
WARNING — HBA first-match-wins: HBA rules are evaluated top-to-bottom. The first matching rule is used. A rule like
host all all all ldap ...matches ALL users from ALL addresses and will prevent password fallback for any user. Always scope LDAP rules to specific users or roles to avoid locking out admin accounts.
SHOW CLUSTER SETTING server.host_based_authentication.configuration;LDAP authentication is configured through HBA (Host-Based Authentication) rules. Always scope LDAP rules to specific databases or users — never use host all all all ldap.
-- Configure HBA for LDAP authentication scoped to specific users
-- The 'root' user and other admin users keep password auth
SET CLUSTER SETTING server.host_based_authentication.configuration = '
host all root all password
host all admin_user all password
host all all all ldap "ldapserver=ldap.example.com" "ldapport=389" "ldapbasedn=dc=example,dc=com" "ldapsearchattribute=uid" "ldapsearchfilter=(objectClass=inetOrgPerson)" "ldapbinddn=cn=readonly,dc=example,dc=com" "ldapbindpasswd=<bind-password>"
host all all all password
';Key LDAP HBA parameters:
ldapserver — LDAP server hostnameldapport — LDAP server port (389 for LDAP, 636 for LDAPS)ldapbasedn — Base DN for user searchldapsearchattribute — Attribute matching the SQL username (e.g., uid for OpenLDAP, sAMAccountName for AD)ldapsearchfilter — Required. LDAP filter to narrow the user search (e.g., (objectClass=inetOrgPerson))ldapbinddn — DN of the service account used for LDAP bind/searchldapbindpasswd — Password for the bind DN service accountImportant: Each HBA option must be quoted as
"key=value"(the entire key=value pair in one set of quotes).
See configuration steps reference for Active Directory, OpenLDAP, group mapping, and LDAPS examples.
For production environments, always use LDAPS (LDAP over TLS on port 636) to encrypt credentials in transit. Do NOT use ldaptls=1 — this option is not supported. Instead, use port 636 and configure the custom CA certificate:
-- Configure the LDAP CA certificate for TLS verification
SET CLUSTER SETTING server.ldap_authentication.domain.custom_ca = '-----BEGIN CERTIFICATE-----
<your-ldap-ca-certificate-pem>
-----END CERTIFICATE-----';
-- Set HBA to use LDAPS (port 636)
SET CLUSTER SETTING server.host_based_authentication.configuration = '
host all root all password
host all admin_user all password
host all all all ldap "ldapserver=ldap.example.com" "ldapport=636" "ldapbasedn=dc=example,dc=com" "ldapsearchattribute=uid" "ldapsearchfilter=(objectClass=inetOrgPerson)" "ldapbinddn=cn=readonly,dc=example,dc=com" "ldapbindpasswd=<bind-password>"
host all all all password
';LDAP group mapping assigns CockroachDB SQL roles based on LDAP/AD group membership. Group mapping is configured via the ldapgrouplistfilter HBA parameter — not via cluster settings.
-- HBA with group-to-role mapping
SET CLUSTER SETTING server.host_based_authentication.configuration = '
host all root all password
host all admin_user all password
host all all all ldap "ldapserver=ad.corp.example.com" "ldapport=636" "ldapbasedn=ou=Users,dc=corp,dc=example,dc=com" "ldapsearchattribute=sAMAccountName" "ldapsearchfilter=(objectClass=user)" "ldapbinddn=cn=crdb-svc,ou=ServiceAccounts,dc=corp,dc=example,dc=com" "ldapbindpasswd=<service-account-password>" "ldapgrouplistfilter=(&(objectClass=group)(member={{.User.DN}}))"
host all all all password
';The LDAP group CN is mapped directly to a SQL role name. The role must already exist in CockroachDB:
CREATE ROLE IF NOT EXISTS db_admins;
GRANT admin TO db_admins;Auto-provision SQL users when they first authenticate via LDAP:
SET CLUSTER SETTING security.provisioning.ldap.enabled = true;# Test with an LDAP user credential
cockroach sql --url "postgresql://<ldap-username>:<ldap-password>@<cluster-host>:26257/defaultdb?sslmode=verify-full"-- Verify the user connected successfully
SELECT current_user();
-- If group mapping is enabled, verify role grants
SHOW GRANTS FOR <ldap-username>;Skip this section if the user does not need automated user provisioning or does not have an Enterprise plan.
SCIM 2.0 enables automated user provisioning and deprovisioning on the Cloud Console, syncing user lifecycle with your IdP.
Check SCIM status in the Cloud Console UI (Organization Settings > Authentication > SCIM). The ccloud CLI does not currently expose SCIM configuration commands.
In your IdP (Okta, Azure AD, etc.):
See configuration steps reference for IdP-specific SCIM setup.
If SSO is enforced and the IdP becomes unavailable or misconfigured:
Prevention: Always create and test a break-glass admin account before enforcing SSO.
"ERROR: JWT authentication: invalid token"
server.jwt_authentication.issuers.configurationserver.jwt_authentication.jwks_auto_fetch.enabled is trueecho '<token>' | cut -d. -f2 | base64 -d | jq .aud (audience) claim in the token matches the configured audience"ERROR: JWT authentication: issuer not configured"
server.jwt_authentication.issuers.configuration"OIDC: unable to match principal"
server.oidc_authentication.principal_regex does not match the claim value from the tokenSHOW CLUSTER SETTING server.oidc_authentication.principal_regex;
-- Common patterns:
-- Email -> username (strip domain): '^([^@]+)'
-- Full email as username: '^(.+)$'Complex regex not accepted:
regexp syntax (no lookaheads/lookbehinds)"ERROR: LDAP authentication: unable to bind"
ldapbinddn and ldapbindpasswd are correctldapsearch -H ldap://ldap.example.com -D "cn=readonly,dc=example,dc=com" -W -b "dc=example,dc=com" "(uid=testuser)""ERROR: LDAP authentication: user not found"
ldapbasedn includes the OU where the user residesldapsearchattribute matches the login attribute (uid for OpenLDAP, sAMAccountName for AD)ldapsearchfilter is set — without it, LDAP user search will failLDAP lockout — all users blocked
host all all all ldap ... is the first rule and the LDAP server is unreachable, or the LDAP config is wrongroot and admin users have explicit password rules BEFORE any ldap ruleroot using client certificate auth (bypasses HBA) and fix the HBA configurationLDAP server unreachable
server.ldap_authentication.domain.custom_caToken audience mismatch:
aud claim that must match the configured audienceserver.jwt_authentication.issuers.configuration matchesserver.oidc_authentication.client_id matchesMulti-tenant vs single-tenant:
https://login.microsoftonline.com/<tenant-id>/v2.0 as the issuerhttps://login.microsoftonline.com/common/v2.0 (requires additional validation)If LDAP authentication fails with "user not found" errors but the user exists in the directory, check whether ldapsearchfilter is included in the HBA rule. This parameter is required and without it the LDAP search may fail silently or return no results.
SSO misconfiguration can lock out users. If SSO is enforced and the IdP is down or misconfigured, no one can log in.
Mitigation — Break-glass account:
HBA first-match-wins — lockout risk: HBA rules are evaluated top-to-bottom. The first matching rule wins. This means:
host all all all ldap ... as the first rule will force ALL users through LDAP — including rootroot and admin users BEFORE LDAP rulesExample of a dangerous configuration:
# DANGEROUS — locks out root if LDAP is unavailable
host all all all ldap ...
host all all all passwordSafe configuration:
# SAFE — root and admins always have password fallback
host all root all password
host all admin_user all password
host all all all ldap ...
host all all all passwordSCIM risks:
LDAP/AD risks:
ldapbinddn account should have minimal read-only permissions. Never use a domain admin account.server.ldap_authentication.domain.custom_ca in production.SET CLUSTER SETTING server.oidc_authentication.enabled = false;SET CLUSTER SETTING server.jwt_authentication.enabled = false;-- Revert HBA to password-only authentication
SET CLUSTER SETTING server.host_based_authentication.configuration = '
host all all all password
';-- Disable JWT auto-provisioning
SET CLUSTER SETTING security.provisioning.jwt.enabled = false;
-- Disable LDAP auto-provisioning
SET CLUSTER SETTING security.provisioning.ldap.enabled = false;SET CLUSTER SETTING server.identity_map.configuration = '';Skill references:
Related skills:
Official CockroachDB Documentation:
84bc1e4
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.