Skip to main content
This topic describes how to enable JSON Web Token authentication in the database. From v3.5.0 onwards, the database supports authenticating client access using JSON Web Tokens. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA. This topic describes how to manually create and authenticate users using JWT in the database. For instructions on how to integrate the database with JWT authentication using security integration, see Authenticate with Security Integration. For more information on how to authenticate user groups using JWT, see Authenticate User Groups.

Prerequisites

If you want to connect to the database from a MySQL client, the MySQL client version must be 9.1 or later. From 9.1, the authentication_openid_connect_client plugin ships with all MySQL client distributions, community distributions included.

Create a user with JWT

When creating a user, specify the authentication method as JWT by IDENTIFIED WITH authentication_jwt [AS '{xxx}']. {xxx} is the JWT properties of the user. In addition to the following method, you can configure the default JWT 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 JWT properties in the FE configuration files, you can directly execute the following statement:

Connect from MySQL client with JWT

To connect from a MySQL client to the database using JWT, you need to enable the authentication_openid-connect_client plugin, and pass the necessary token (using the path to the token file) to authenticate the mapped user. Syntax:
Example:

Connect over HTTP or Arrow Flight with JWT

Users of a JWT security integration can also send the token as Authorization: Bearer <token> to the HTTP API (SQL API, Stream Load, Web UI) and to Arrow Flight SQL, with no user name. See Connect over HTTP and Arrow Flight.
A user created with IDENTIFIED WITH authentication_jwt can present its token only over the MySQL protocol, where the handshake carries the user name. To use a JWT on the HTTP API or Arrow Flight SQL, create a JWT security integration instead, and see Where each authentication method works.