- Cluster single sign-on (SSO): Enables users to access the SQL interface of a CockroachDB cluster (whether provisioned on CockroachDB CockroachDB Cloud or CockroachDB) with the full security of single sign-on (SSO), and the choice of a variety of cloud-based or customer-managed identity providers (IdPs).
- Single sign-on (SSO) for DB Console: Allows a CockroachDB user to access the in a secure cluster via an OpenID Connect (OIDC) client and an external identity provider. When SSO is configured and enabled, the will display an OAuth login button in addition to the password access option.
- The login flow for users, once a cluster is SSO-enabled.
- Provision an OIDC client for CockroachDB Cluster SSO authentication using GCP.
- Configure a CockroachDB Cluster for OIDC SSO authentication to the DB Console.
- IdP: You must have access to an OAuth 2.0 identity provider and client. The process of provisioning one with Google Cloud Platform is described on this page in the Provision an OAuth client using Google Cloud Platform (GCP) section.
-
CockroachDB cluster: you must have access to one of the following:
- A CockroachDB cluster enabled with a valid .
- A .
Log in to a cluster’s DB Console with SSO
From the user’s perspective, once the cluster is properly configured to an identity provider, the sign-in flow is as follows:- A user opens the cluster’s DB Console, and clicks on the Log in with your OIDC provider button that renders on the page.
- The user is redirected to an external identity provider.
- The user authenticates successfully with the provider, which completes the OAuth flow.
- The user is redirected to the CockroachDB cluster.
- CockroachDB creates a web session for the SQL user in a new browser tab.
- In the original browser tab, the user is redirected to the .
Provision an OAuth client using Google Cloud Platform (GCP)
These steps demonstrate how to create an OIDC auth client in Google Cloud Platform to use for SSO authentication to the DB Console.- Open the Credentials page for your account at Google APIs.
- Click + CREATE CREDENTIALS and select OAuth client ID. Specify a web application from the pulldown menu.
- Note the client ID and client secret of the OAuth 2.0 client—you will need to configure your cluster to use these values.
-
Add your cluster’s callback URL to the list of Authorized redirect URIs. On a local cluster, this will be
https://{ your cluster's domain }:8080/oidc/v1/callback. Subsequently, when configuring your cluster, you will need to ensure that the cluster settingserver.oidc_authentication.redirect_urlhas the same value.- For a CockroachDB cluster, the domain is
localhost. - For a CockroachDB Dedicated cluster, find the domain by opening the DB Console from your cluster’s Tools tab in DB Console.
- For a CockroachDB cluster, the domain is
Configure your cluster to use an OIDC client and provider
Prerequisites: You must have the ability to update your cluster settings, which you can achieve in several ways. Refer to the Required Privileges section on the page.Cluster Settings
You must configure the in the following table to enable SSO authentication to the DB Console. Refer to the Update your cluster settings section to configure your cluster settings.Update your cluster settings
-
Open a SQL shell to your cluster:
-
Specify the client ID and client secret you obtained earlier:
-
Specify the OAuth provider URL:
-
Specify the callback URL to redirect the user to the CockroachDB cluster. On a local cluster, this will be
https://localhost:8080/oidc/v1/callback. For a CockroachDB Dedicated cluster, replace ‘localhost’ with your cluster’s domain, which can be found by opening the DB Console from the Tools tab in your cluster’s page in Cloud Console. -
Specify the following values to obtain an OIDC identifier that will be mapped to a SQL user.
Request the
openidandemailscopes from the Access Token:Specify theemailfield from the ID Token:Use a regular expression that will extract a username fromemailthat you can match to a SQL user. For example,'^([^@]+)@cockroachlabs\.com$'extracts the characters that precede@cockroachlabs.comin the email address. -
that will log into the DB Console. The SQL username you specify must match the identifier obtained in the previous step. For example, a user with the email address
docs@cockroachlabs.comwill need the SQL usernamedocs: -
Finally, enable OIDC authentication:
You can optionally enable the to automatically log in an authenticated user who visits the DB Console.

