Authentication on CockroachDB Cloud

On this page Carat arrow pointing down

Users may connect with CockroachDB Cloud at two levels, the organization and the cluster, both of which are covered in this page.

Refer to: Overview of the CockroachDB Cloud authorization model.

Overview of CockroachDB Cloud authentication

Organization level functions can be performed through three different interfaces, each with its own authentication flows:

Cluster level functions, i.e. SQL statements, are executed by SQL clients.

Refer to: SQL client authentication

Console UI authentication

You may log in to the CockroachDB Cloud Console with a username and password, or by using Single Sign-on (SSO) for CockroachDB Cloud.

Note:
We recommend that CockroachDB Cloud Console users log in with Single Sign-On (SSO), optionally with two-factor authentication (2FA) enabled for the SSO provider. This prevents potential attackers from using stolen credentials to access or tamper with your critical data.

CockroachDB Cloud Basic SSO supports SSO with GitHub, Google, and Microsoft. Cloud Organization SSO provides additional configuration and flexibility, and includes support for OIDC or SAML protocols, autoprovisioning, and limiting the email domains that can use a given authentication method.

Visit your CockroachDB Cloud Console's account settings page and switch to SSO to improve the security of your cluster.

ccloud authentication

The ccloud utility offers Organization users a way to script many functions that must otherwise be performed in the console interface.

For more information, refer to: Get Started with the ccloud CLI

To authenticate ccloud to a particular organization, run the following command. ccloud will open up your machine's default browser, attempt to authenticate to the console and export a temporary auth token.

icon/buttons/copy
ccloud auth login --org <organization label>

Refer to: Log in to CockroachDB Cloud using ccloud auth

Cloud API authentication

The Cloud API allows automated execution of organization functions. Unlike ccloud and the console UI, however, the API can not be authenticated by human users, but by service accounts.

Service accounts authenticate to the API using API keys, which are provisioned through the console UI.

Refer to: Managing Service Accounts: API access

SQL client authentication

To execute SQL statements or perform database administration functions on a cluster, you must connect to the cluster with a SQL client. CockroachDB clients include the CockroachDB CLI, and numerous drivers and object-relational mapping (ORM) tools.

The connection string

You can obtain a connection string or CLI command for your cluster, to use with your choice of SQL client, by visiting your cluster's overview page, and clicking Connect button, and following the instructions.

https://cockroachlabs.cloud/cluster/< your cluster UUID >/

Clients can authenticate in two ways. Your connection string must be modified depending on which you are using:

Note that the TLS public root certificate authority (CA) certificate of the cluster is also required for authenticating the cluster server against the SQL client. This certificate can be downloaded by following the instructions in the Connect UI.

Username and password

A user can authenticate to a cluster by providing their username and password in the connection string.

The connection string UI will indicate how to modify the string to user credentials.

For information on managing SQL user credentials, including provisioning passwords, refer to Manage SQL users on a cluster.

PKI security certificate

SQL clients may authenticate to CockroachDB Dedicated clusters using PKI security certificates.

Refer to Transport Layer Security (TLS) and Public Key Infrastructure (PKI) for an overview of PKI certificate authentication in general and its use in CockroachDB.

Refer to Certificate Authentication for SQL Clients in CockroachDB Dedicated Clusters for procedural information on administering and using client certificate authentication.

Node identity verification

The connection string generated to connect to your application uses the verify-full SSL mode by default to verify a node’s identity. This mode encrypts the data in-flight as well as verifies the identity of the CockroachDB node, thus ensuring a secure connection to your cluster. Using this mode prevents MITM (Machine in the Middle) attacks, impersonation attacks, and eavesdropping.

To connect securely to your cluster using the verify-full mode:

  1. Download the CA certificate and place it in the certs directory. The Certificate Authority (CA) certificate is the file that the client uses to verify the identity of the CockroachDB node.
  2. When connecting to the cluster, specify the path to the certs directory in the connection string. See Connect to your cluster for more details.

You can also use the require SSL mode, although we do not recommend using it since it can make the cluster susceptible to MITM and impersonation attacks. For more information, see the "Protection Provided in Different Modes" section in PostgreSQL's SSL Support document.

For more information about creating SQL users and passwords, see User Authorization.

SSL mode settings

The table below lists the sslmode settings you can use to connect to your cluster and their associated security risks. Other settings are not recommended.

sslmode Eavesdropping protection MITM protection Description
require Yes No Force a secure connection. An error occurs if the secure connection cannot be established. This is less secure than using a CA certificate and is only recommended for testing or unimportant data.
verify-full Yes Yes Force a secure connection, verify that the server certificate is signed by a known CA, and verify that the server address matches that specified in the certificate.

See also


Yes No
On this page

Yes No