Skip to main content
This topic describes how to enable OAuth 2.0 authentication in the database. From v3.5.0 onwards, the database supports authenticating client access using OAuth 2.0. You can enable OAuth 2.0 authentication over HTTP for the Web UI and the JDBC driver. The database uses the Authorization Code flow which exchanges an authorization code for a token. Generally, the flow includes the following steps:
  1. The database coordinator redirects the user’s browser to the Authorization Server.
  2. The user authenticates from the Authorization Server.
  3. After the request is approved, the browser is redirected back to the database FE with an authorization code.
  4. the database coordinator exchanges the authorization code for a token.
This topic describes how to manually create and authenticate users using OAuth 2.0 in the database. For instructions on how to integrate the database with your OAuth 2.0 service using security integration, see Authenticate with Security Integration. For more information on how to authenticate user groups in your OAuth 2.0 service, see Authenticate User Groups.

Prerequisites

If you want to connect to the database from a MySQL client, the MySQL client version must be 9.2 or later. For more information, see MySQL official document.

Create a user with OAuth 2.0

When creating a user, specify the authentication method as OAuth 2.0 by IDENTIFIED WITH authentication_oauth2 [AS '{xxx}']. {xxx} is the OAuth 2.0 properties of the user. In addition to the following method, you can configure the default OAuth 2.0 properties in the FE configuration file. You need to manually modify all fe.conf files and restart all FEs for configuration to take effect. After the FE configurations are set, the database will use the default properties specified in your configuration file and you can omit the AS '{xxx}' part. Syntax:
Example:
If you have set the OAuth 2.0 properties in the FE configuration files, you can directly execute the following statement:

Connect from JDBC client with OAuth 2.0

The database supports the MySQL protocol. You can customize a MySQL plugin to automatically launch the browser login method. For the example code of the JDBC OAuth2 plugin, see the official document for starrocks-jdbc-oauth2-plugin.

Connect from MySQL client with OAuth 2.0

If you cannot access a browser in your environment (such as using terminal or server), you can also access the database via native MySQL client or JDBC driver:
  • When you first connect to the database, a URL will be returned.
  • You need to access this URL on a browser and complete the authentication.
  • After the authentication, you can then interact with the database.

Connect over HTTP or Arrow Flight with OAuth 2.0

An access token issued by the OAuth 2.0 provider can also be sent as Authorization: Bearer <token> to the HTTP API and to Arrow Flight SQL. The database verifies it against the jwks_url, required_issuer and required_audience of the OAuth 2.0 security integration, with no browser round trip. See Connect over HTTP and Arrow Flight.
A user created with IDENTIFIED WITH authentication_oauth2 can only complete the browser flow over the MySQL protocol. To accept an access token on the HTTP API or Arrow Flight SQL, create an OAuth 2.0 security integration, which acts as a Resource Server, and see Where each authentication method works.