- The database coordinator redirects the user’s browser to the Authorization Server.
- The user authenticates from the Authorization Server.
- After the request is approved, the browser is redirected back to the database FE with an authorization code.
- the database coordinator exchanges the authorization code for a token.
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 byIDENTIFIED 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:
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 asAuthorization: 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.