> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticate with Security Integration

> Integrate the database with external authentication systems using security integration.

Integrate the database with external authentication systems using security integration.

By creating a security integration within your cluster, you can allow access of your external authentication service to the database. With the security integration, you do not need to manually create users within the database. When a user tries to log in using an external identity, the database will use the corresponding security integration according to the configuration in `authentication_chain` to authenticate the user. After the authentication is successful and the user is allowed to log in, the database creates a virtual user in the session for the user to perform subsequent operations.

Please note that if you use the security integration to configure an external authentication method, you must also [integrate the database with Apache Ranger](/documents/4.2/administration/user_privs/authorization/ranger_plugin.md) to enable external authorization. Currently, integrating Security Integration with the database native authorization is not supported.

You can also enable [Group Provider](/documents/4.2/administration/user_privs/group_provider.md) for the database to access the group information in you external authentication systems, thus allowing creating, authenticating, and authorizing user groups in the database.

Manually creating and managing users with external authentication services are also supported in case of specific corner cases. For more instructions, you can refer to [See also](#see-also).

## Create a security integration

Currently, the database' security integration supports the following authentication systems:

* LDAP
* JSON Web Token (JWT)
* OAuth 2.0

**Note**

The database does not offer connectivity checks when you create a security integration.

### Create a security integration with LDAP

#### Syntax

```SQL theme={null}
CREATE SECURITY INTEGRATION <security_integration_name> 
PROPERTIES (
    "type" = "authentication_ldap_simple",
    "authentication_ldap_simple_server_host" = "",
    "authentication_ldap_simple_server_port" = "",
    "authentication_ldap_simple_bind_base_dn" = "",
    "authentication_ldap_simple_user_search_attr" = "",
    "authentication_ldap_simple_bind_root_dn" = "",
    "authentication_ldap_simple_bind_root_pwd" = "",
    "authentication_ldap_simple_bind_dn_pattern" = "",
    "authentication_ldap_simple_ssl_conn_allow_insecure" = "{true | false}",
    "authentication_ldap_simple_ssl_conn_trust_store_path" = "",
    "authentication_ldap_simple_ssl_conn_trust_store_pwd" = "",
    "comment" = ""
)
```

#### Parameters

##### security\_integration\_name

* Required: Yes
* Description: The name of the security integration.\
  **NOTE**\
  The security integration name is globally unique. You cannot specify this parameter as `native`.

##### type

* Required: Yes
* Description: The type of the security integration. Specify it as `authentication_ldap_simple`.

##### authentication\_ldap\_simple\_server\_host

* Required: No
* Description: The IP address of your LDAP service. Default: `127.0.0.1`.

##### authentication\_ldap\_simple\_server\_port

* Required: No
* Description: The port of your LDAP service. Default: `389`.

##### authentication\_ldap\_simple\_bind\_base\_dn

* Required: No
* Description: The base Distinguished Name (DN) of the LDAP user for which the cluster searches. Required when using search-and-bind mode. Not needed when using direct bind mode with `authentication_ldap_simple_bind_dn_pattern`.

##### authentication\_ldap\_simple\_user\_search\_attr

* Required: No
* Description: The attribute of a user entry that carries the login name. It is interpolated into the search filter of search-and-bind mode, so it must be the attribute whose value the user actually types when logging in. Default: `uid`, the convention on OpenLDAP, where it is usually also the entry's RDN (`uid=alice,ou=People,dc=example,dc=com`). Not used in direct bind mode.

**On Active Directory, set this to `sAMAccountName`**

An AD entry's RDN is the display name (`CN=Dana Scully,OU=People,DC=company,DC=com`), while the name a user types to log in is its `sAMAccountName` (`dscully`). AD's schema does contain `uid`, but it holds no value unless an administrator populated it, so the default finds nobody and every login fails. Two settings follow from this choice:

* **Use search-and-bind, not direct bind.** `sAMAccountName` is not part of an AD entry's DN, so no `authentication_ldap_simple_bind_dn_pattern` can produce one. Leave that property unset and set `authentication_ldap_simple_bind_base_dn`, `authentication_ldap_simple_bind_root_dn` and `authentication_ldap_simple_bind_root_pwd` instead.
* **A Group Provider cannot match members by `sAMAccountName` either.** An AD group lists its members by DN (`member: CN=Dana Scully,OU=People,...`), and that DN carries no `sAMAccountName`, so a group provider configured with `"ldap_user_search_attr" = "sAMAccountName"` matches nobody. Either leave the group provider's own `ldap_user_search_attr` unset, so that it matches by DN, or read the groups from the user's own entry with `authentication_ldap_simple_group_source = memberof`.

**Note**

**DN Passing Mechanism**: LDAP security integration supports DN passing functionality.

* After successful authentication, the system records both the user's login name and complete DN.
* When combined with Group Provider, DN information is automatically passed to the Group Provider.
* If `ldap_user_search_attr` is not configured for the Group Provider, DN will be used for group matching.
* This mechanism is particularly suitable for complex LDAP environments like Microsoft AD.

For more details, see the DN matching mechanism in [Authenticate User Groups](/documents/4.2/administration/user_privs/group_provider.md).

##### authentication\_ldap\_simple\_bind\_root\_dn

* Required: No
* Description: The admin DN of your LDAP service. Required when using search-and-bind mode.

##### authentication\_ldap\_simple\_bind\_root\_pwd

* Required: No
* Description: The admin password of your LDAP service. Required when using search-and-bind mode.

##### authentication\_ldap\_simple\_bind\_dn\_pattern

* Required: No
* Description: The DN pattern for direct bind authentication. Use `${USER}` as a placeholder for the username. The pattern must produce a valid LDAP Distinguished Name (DN); UPN-style patterns like `${USER}@domain` are not supported. For example, `uid=${USER},ou=People,dc=example,dc=com`. Multiple patterns can be separated by semicolons, and the system will try each pattern in order until one succeeds. When this parameter is set, the system skips the search step and directly binds with the constructed DN, so `authentication_ldap_simple_bind_base_dn`, `authentication_ldap_simple_user_search_attr`, `authentication_ldap_simple_bind_root_dn`, and `authentication_ldap_simple_bind_root_pwd` are not required.

##### authentication\_ldap\_simple\_group\_source

* Required: No
* Description: Where the groups of an LDAP-authenticated user come from. Valid values:

  * `group_provider` (default): only the group providers configured in `group_provider` are used. This is the behavior of earlier versions.
  * `memberof`: only the group membership attribute of the user's own LDAP entry is used. Group providers configured in `group_provider` are ignored, but the configuration is kept, so switching back only takes one `ALTER SECURITY INTEGRATION`.
  * `both`: the union of the two sources.

  With `memberof` or `both`, a group newly created in the directory takes effect on the next login without any configuration change here. The resolved groups take part in role mapping via `GRANT ... TO EXTERNAL GROUP`, in the `permitted_groups` login check, in `current_group()`, and in Apache Ranger authorization, exactly like the groups of a group provider. The cluster-wide default is the FE configuration item of the same name. Supported from v4.2 onwards.

##### authentication\_ldap\_simple\_memberof\_attr

* Required: No
* Description: The name of the attribute on the user entry that carries its group membership, used when `authentication_ldap_simple_group_source` is `memberof` or `both`. Matched ignoring case, like every LDAP attribute name. Default: `memberOf`, which fits Active Directory and OpenLDAP with the `memberof` overlay installed. Oracle Directory Server and 389 Directory Server use `isMemberOf`. The cluster-wide default is the FE configuration item of the same name. Supported from v4.2 onwards.

**Reading group membership from the user entry**

* Only direct membership is resolved. Nested groups, the Active Directory primary group (`Domain Users` by default), and groups from another domain or forest are not included, because they do not appear in the attribute.
* The group name is the value of the first RDN of each group DN. For example, `CN=SR Analysts,OU=Groups,DC=company,DC=com` becomes `SR Analysts`. The original case is kept.
* The attribute is read on the connection that authentication already opened, so no additional LDAP connection is made. In search-and-bind mode the number of requests does not change at all; in direct bind mode (`authentication_ldap_simple_bind_dn_pattern`) one read request is added, because a bind response cannot carry attributes.
* In direct bind mode the user reads its own attribute. If the directory does not allow that and `authentication_ldap_simple_bind_root_dn` and `authentication_ldap_simple_bind_root_pwd` are set, the FE retries once with that account, so there is no need to change the authentication mode. If neither reader can see the attribute, the group set is empty and the login still succeeds.
* If the group set is empty and `permitted_groups` is set, the user is rejected, because the intersection is necessarily empty.
* The group set is computed at login and stored in the session. A membership change in the directory takes effect on the next login, not in a running session.
* The legacy per-user form `CREATE USER ... IDENTIFIED WITH authentication_ldap_simple AS '<dn>'` does not support this feature. Use a security integration instead.
* `EXECUTE AS` resolves the groups of the **target** identity from that identity's own configuration: a native-password user has no LDAP identity and only gets its group providers, while `EXECUTE AS EXTERNAL USER` uses the first `authentication_ldap_simple` integration of `authentication_chain`. Impersonation never presents the target's password, so the attribute is read with `authentication_ldap_simple_bind_root_dn` and `authentication_ldap_simple_bind_root_pwd`; with no service account configured, only the group providers contribute.

##### authentication\_ldap\_simple\_ssl\_conn\_allow\_insecure

* Required: No
* Description: Whether to allow non-encrypted connections to the LDAP server. Default value: `true`. Setting this value to `false` indicates that SSL encryption is required to access LDAP.

##### authentication\_ldap\_simple\_ssl\_conn\_trust\_store\_path

* Required: No
* Description: Local path to store the SSL CA certificate of the LDAP server. Supports pem and jks formats. You do not need to set this item if the certificate is issued by a trusted organization.

##### ldap\_ssl\_conn\_trust\_store\_pwd

* Required: No
* Description: The password used to access the locally stored SSL CA certificate of the LDAP server. pem-formatted certificates do not require a password. Only jsk-formatted certificates do.

##### group\_provider

* Required: No
* Description: The name of the group provider(s) to be combined with the security integration. Multiple group providers are separated by commas. Once set, the database will record the user's group information under each specified provider upon login. Supported from v3.5 onwards. For detailed instructions on enabling Group Provider, see [Authenticate User Groups](/documents/4.2/administration/user_privs/group_provider.md).

##### permitted\_groups

* Required: No
* Description: The name of group(s) whose members are allowed to log in to the database. Multiple groups are separated by commas. Make sure that the specified groups can be retrieved by the combined group provider(s). Supported from v3.5 onwards.

##### comment

* Required: No
* Description: The description of the security integration.

### Create a security integration with JWT

#### Syntax

```SQL theme={null}
CREATE SECURITY INTEGRATION <security_integration_name>
PROPERTIES (
    "type" = "authentication_jwt",
    "jwks_url" = "",
    "principal_field" = "",
    "required_issuer" = "",
    "required_audience" = "",
    "group_source" = "",
    "group_claim" = "",
    "comment" = ""
);
```

#### Parameters

##### security\_integration\_name

* Required: Yes
* Description: The name of the security integration.\
  **NOTE**\
  The security integration name is globally unique. You cannot specify this parameter as `native`.

##### type

* Required: Yes
* Description: The type of the security integration. Specify it as `jwt`.

##### jwks\_url

* Required: Yes
* Description: The URL to the JSON Web Key Set (JWKS) service or the path to the local file under the `fe/conf` directory.

##### principal\_field

* Required: Yes
* Description: The field in the JWT that identifies the subject. The default value is `sub`. The value of this field must be identical with the username for logging in to the database. To extract a value from a nested claim, specify an [RFC 6901 JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) (a path starting with `/`). Use `~1` to escape `/` and `~0` to escape `~` in key names. For example, `/https:~1~1sts.amazonaws.com~1/request_tags/starrocks_user` resolves the `starrocks_user` field nested under the URI-namespaced claim `https://sts.amazonaws.com/`.

##### required\_issuer

* Required: No
* Description: The list of strings used to identify the issuers (`iss`) in the JWT. The JWT is considered valid only if one of the values in the list match the JWT issuer.

##### required\_audience

* Required: No
* Description: The list of strings used to identify the audience (`aud`) in the JWT. The JWT is considered valid only if one of the values in the list match the JWT audience.

##### group\_source

* Required: No
* Description: Where the groups of a user authenticated by this integration come from. Valid values:

  * `group_provider` (default): only the group providers listed in `group_provider` are used. This is the behavior of earlier versions.
  * `claim`: only the claim named by `group_claim` of the verified token is used. Group providers listed in `group_provider` are ignored, but their configuration is kept, so switching back takes one `ALTER SECURITY INTEGRATION`.
  * `both`: the union of the two sources.

  Taking the groups from the token is what lets an identity provider with no LDAP directory grant any privilege at all: the resolved groups take part in role mapping via `GRANT ... TO EXTERNAL GROUP`, in the `permitted_groups` login check, in `current_group()`, and in Apache Ranger authorization, exactly like the groups of a group provider. Supported from v4.2 onwards.

##### group\_claim

* Required: Yes when `group_source` is `claim` or `both`. Setting it without `group_source` is refused, because it would have no effect; together with an explicit `group_source` of `group_provider` it is accepted and kept, so the claim can be put in place before an `ALTER SECURITY INTEGRATION` switches the source.
* Description: The claim of the token that holds the user's groups, dot-separated for a claim nested inside another object. For example, `groups` for a top-level claim, `realm_access.roles` for the realm roles of Keycloak, and `resource_access.<client_id>.roles` for its client roles. The claim should hold an array of strings; a single string is accepted as one group. Surrounding whitespace is removed from each name; nothing else is rewritten - not the case, not a leading slash - because the names are handed to Apache Ranger, which matches them exactly. Whether a name matches a `GRANT ... TO EXTERNAL GROUP` or `permitted_groups` entry that differs only in case is decided by the FE configuration item `authentication_group_case_insensitive` (ignoring case by default; set it to `false` if your identity provider distinguishes groups by case).

  There is deliberately no default: the claim an identity provider emits differs per provider, and a wrong guess would let users log in with no privileges instead of failing visibly. The claim is read only after the signature, the required issuer and the required audience have been verified, so the holder of a token cannot choose their own groups. If the claim is absent from a token, the login still succeeds with no groups and the reason is logged rather than reported as an authentication failure - Microsoft Entra ID drops the claim entirely for a user in more than 200 groups, so an absent claim is a state a correct configuration produces. Note that most identity providers do not put groups in a token unless asked to: Keycloak needs a group membership mapper on the client, and Entra ID needs the groups claim added to the token configuration. Supported from v4.2 onwards.

##### comment

* Required: No
* Description: The description of the security integration.

### Create a security integration with OAuth 2.0

#### Syntax

```SQL theme={null}
CREATE SECURITY INTEGRATION <security_integration_name>
PROPERTIES (
    "type" = "authentication_oauth2",
    "auth_server_url" = "",
    "token_server_url" = "",
    "client_id" = "",
    "client_secret" = "",
    "redirect_url" = "",
    "jwks_url" = "",
    "principal_field" = "",
    "required_issuer" = "",
    "required_audience" = "",
    "group_source" = "",
    "group_claim" = "",
    "comment" = ""
)
```

#### Parameters

##### security\_integration\_name

* Required: Yes
* Description: The name of the security integration.\
  **NOTE**\
  The security integration name is globally unique. You cannot specify this parameter as `native`.

##### auth\_server\_url

* Required: Yes
* Description: The authorization URL. The URL to which the users’ browser will be redirected in order to begin the OAuth 2.0 authorization process.

##### token\_server\_url

* Required: Yes
* Description: The URL of the endpoint on the authorization server from which the database obtains the access token.

##### client\_id

* Required: Yes
* Description: The public identifier of the database client.

##### client\_secret

* Required: Yes
* Description: The secret used to authorize the database client with the authorization server.

##### redirect\_url

* Required: Yes
* Description: The URL to which the users’ browser will be redirected after the OAuth 2.0 authentication succeeds. The authorization code will be sent to this URL. In most cases, it need to be configured as `http://<starrocks_fe_url>:<fe_http_port>/api/oauth2`.

##### type

* Required: Yes
* Description: The type of the security integration. Specify it as `authentication_oauth2`.

##### jwks\_url

* Required: Yes
* Description: The URL to the JSON Web Key Set (JWKS) service or the path to the local file under the `fe/conf` directory.

##### principal\_field

* Required: Yes
* Description: The field in the JWT that identifies the subject. The default value is `sub`. The value of this field must be identical with the username for logging in to the database. To extract a value from a nested claim, specify an [RFC 6901 JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) (a path starting with `/`). Use `~1` to escape `/` and `~0` to escape `~` in key names. For example, `/https:~1~1sts.amazonaws.com~1/request_tags/starrocks_user` resolves the `starrocks_user` field nested under the URI-namespaced claim `https://sts.amazonaws.com/`.

##### required\_issuer

* Required: No
* Description: The list of strings used to identify the issuers (`iss`) in the JWT. The JWT is considered valid only if one of the values in the list match the JWT issuer.

##### required\_audience

* Required: No
* Description: The list of strings used to identify the audience (`aud`) in the JWT. The JWT is considered valid only if one of the values in the list match the JWT audience.

##### group\_source

* Required: No
* Description: Where the groups of a user authenticated by this integration come from. Valid values:

  * `group_provider` (default): only the group providers listed in `group_provider` are used. This is the behavior of earlier versions.
  * `claim`: only the claim named by `group_claim` of the verified token is used. Group providers listed in `group_provider` are ignored, but their configuration is kept, so switching back takes one `ALTER SECURITY INTEGRATION`.
  * `both`: the union of the two sources.

  Taking the groups from the token is what lets an identity provider with no LDAP directory grant any privilege at all: the resolved groups take part in role mapping via `GRANT ... TO EXTERNAL GROUP`, in the `permitted_groups` login check, in `current_group()`, and in Apache Ranger authorization, exactly like the groups of a group provider. For an OAuth 2.0 integration this also covers the browser login over the MySQL protocol: there the token reaches the database only after the user has signed in through the browser, so the groups are read from the ID token when it arrives, and `permitted_groups` is checked on the first statement after the browser login rather than when the connection opens. With `group_source` left at `group_provider`, nothing changes: the groups and the check are decided when the connection opens, as before. Supported from v4.2 onwards.

##### group\_claim

* Required: Yes when `group_source` is `claim` or `both`; setting it with any other `group_source` is refused, because it would have no effect.
* Description: The claim of the token that holds the user's groups, dot-separated for a claim nested inside another object. For example, `groups` for a top-level claim, `realm_access.roles` for the realm roles of Keycloak, and `resource_access.<client_id>.roles` for its client roles. The claim should hold an array of strings; a single string is accepted as one group. Surrounding whitespace is removed from each name; nothing else is rewritten - not the case, not a leading slash - because the names are handed to Apache Ranger, which matches them exactly. Whether a name matches a `GRANT ... TO EXTERNAL GROUP` or `permitted_groups` entry that differs only in case is decided by the FE configuration item `authentication_group_case_insensitive` (ignoring case by default; set it to `false` if your identity provider distinguishes groups by case).

  There is deliberately no default: the claim an identity provider emits differs per provider, and a wrong guess would let users log in with no privileges instead of failing visibly. The claim is read only after the signature, the required issuer and the required audience have been verified, so the holder of a token cannot choose their own groups. If the claim is absent from a token, the login still succeeds with no groups and the reason is logged rather than reported as an authentication failure - Microsoft Entra ID drops the claim entirely for a user in more than 200 groups, so an absent claim is a state a correct configuration produces. Note that most identity providers do not put groups in a token unless asked to: Keycloak needs a group membership mapper on the client, and Entra ID needs the groups claim added to the token configuration. Supported from v4.2 onwards.

##### comment

* Required: No
* Description: The description of the security integration.

## Configure authentication chain

After the security integration is created, it is added to your cluster as a new authentication method. You must enable the security integration by setting the order of the authentication methods via the FE dynamic configuration item `authentication_chain`.

```SQL theme={null}
ADMIN SET FRONTEND CONFIG (
    "authentication_chain" = "<security_integration_name>[... ,]"
);
```

**Note**

* The database first checks for a matching local account and uses that account's authentication method. If its authentication fails, the database does not fall back to a security integration with the same username.
* You can specify multiple security integrations in `authentication_chain` except for OAuth 2.0 security integration. You cannot specify multiple OAuth 2.0 security integrations or one with other security integrations.
* For MySQL connections without a matching local account, `authentication_ldap_simple` and `authentication_jwt` integrations can coexist. During the handshake, the database skips `native` and removed integrations, and selects the first integration whose client plugin matches the client's declaration. If none matches, it selects the first remaining integration and uses the existing plugin negotiation. This rule applies uniformly to all plugins.
* To use LDAP when no plugin matches, put the LDAP integration first among the security integrations, for example, `native,corp_ldap,corp_jwt`. This also determines the fallback for clients declaring `mysql_native_password` or an empty plugin name. An explicitly matching plugin selects its integration regardless of preceding integrations using other plugins. Chains containing only one mechanism retain their previous handshake behavior, and credentials must still pass verification.
* Use `type = authentication_ldap_simple` for new LDAP integrations. The legacy `type = ldap` is retained for compatibility and is not recommended for new configurations.
* For client plugin settings and the JWT-as-password option, see [Mix LDAP and JWT security integrations](#mix-ldap-and-jwt-security-integrations).

You can check the value of `authentication_chain` using the following statement:

```SQL theme={null}
ADMIN SHOW FRONTEND CONFIG LIKE 'authentication_chain';
```

### Mix LDAP and JWT security integrations

Over HTTP and Arrow Flight, LDAP and JWT security integrations on one `authentication_chain` work side by side, because the credential itself says what it is: `Basic` (user name and password) is tried against the LDAP security integrations, and `Bearer` (a token) against the JWT and OAuth 2.0 security integrations. See [Connect over HTTP and Arrow Flight](#connect-over-http-and-arrow-flight).

Over the MySQL protocol the support is partial. The database has to choose one client authentication plugin for a connection before it sees any credential, and the two kinds of security integration need different plugins: `mysql_clear_password` for LDAP and `authentication_openid_connect_client` for JWT. The database chooses by the plugin the client declares in its handshake:

| The client declares | Security integration used |
| - | - |
| `authentication_openid_connect_client` | The first JWT security integration on the chain |
| `mysql_clear_password` | The first LDAP security integration on the chain |
| Neither (most clients send `mysql_native_password` by default) | The first security integration on the chain |

Therefore:

* Put first the security integration that most of your clients use without any extra setting.
* Clients of the other kind must declare their plugin: `--default-auth=<plugin>` with the MySQL client, `defaultAuthenticationPlugin=<plugin>` with MySQL Connector/J. The MySQL client includes `authentication_openid_connect_client` from version 9.1, community distributions included. Older MySQL clients and the MariaDB client do not have this plugin.
* A client that cannot declare a plugin, such as PyMySQL, always gets the first security integration on the chain.

```Bash theme={null}
# A JWT security integration user, with the LDAP security integration first on the chain
mysql -h <fe_host> -P <query_port> --default-auth=authentication_openid_connect_client \
    --authentication-openid-connect-client-id-token-file=<path_to_token_file> -u <username>

# An LDAP security integration user, with the JWT security integration first on the chain
mysql -h <fe_host> -P <query_port> --default-auth=mysql_clear_password --enable-cleartext-plugin -u <username> -p
```

If your JWT clients cannot load the OpenID Connect plugin, set the FE configuration item `authentication_chain_accept_jwt_as_password` to `true` and put the LDAP security integration first. A JWT client then passes its token as the password: when the password of a MySQL login has the shape of a JWT, the database first verifies it against the JWT and OAuth 2.0 security integrations, and only if none accepts it tries it as a password against the LDAP security integrations. The token travels like a clear-text password, so use an SSL connection. This item applies to the MySQL protocol only; over HTTP and Arrow Flight, send the token as `Bearer`.

```Bash theme={null}
mysql -h <fe_host> -P <query_port> --ssl-mode=REQUIRED --enable-cleartext-plugin -u <username> -p"$(cat <path_to_token_file>)"
```

## Connect over HTTP and Arrow Flight

A user of a security integration on `authentication_chain` can log in over every the database entry point, not only the MySQL protocol: the HTTP SQL API, Stream Load (through an FE or directly against a BE), the FE Web UI, and Arrow Flight SQL. The credential the client sends depends on the type of the integration.

| Integration type | HTTP | Arrow Flight SQL |
| - | - | - |
| LDAP (`authentication_ldap_simple`) | HTTP Basic: `-u <username>:<password>` | username and password |
| JWT (`authentication_jwt`), OAuth 2.0 (`authentication_oauth2`) | `Authorization: Bearer <token>` | `Authorization: Bearer <token>` header, for example the ADBC `adbc.flight.sql.authorization_header` option |

A Bearer token needs no user name. The database reads the user name from the claim named by `principal_field`, verifies the signature against `jwks_url`, and offers the token to every JWT and OAuth 2.0 integration on the chain whose `required_issuer` and `required_audience` (if set) match the token. When several integrations share one issuer, set a distinct `required_audience` on each: the token's `aud` claim then decides which integration, and therefore which group provider and roles, the connection gets. Setting `required_issuer` on every integration is strongly recommended.

Examples:

```Bash theme={null}
# SQL API with an LDAP integration user
curl -u alice:alice_password -H 'Content-Type: application/json' -XPOST \
    http://<fe_host>:<fe_http_port>/api/v1/catalogs/default_catalog/databases/<db>/sql \
    -d '{"query": "select current_user()"}'

# Stream Load with a JWT, directly against a BE (the BE must run with enable_http_auth = true)
curl -H "Authorization: Bearer ${TOKEN}" -H "label:load_1" -H "column_separator:," \
    -T data.csv -XPUT http://<be_host>:<be_http_port>/api/<db>/<table>/_stream_load
```

Note the following points:

* Privileges for security-integration users come from [Group Provider](/documents/4.2/administration/user_privs/group_provider.md) and `GRANT ... TO EXTERNAL GROUP` only; the groups a user is resolved into apply on every entry point.
* On Arrow Flight SQL, a JWT is authenticated exactly like a user name and password: the server answers with its own session token, which the client uses for the rest of the connection. The session cannot outlive the JWT; once the token's `exp` passes, the connection is refused and the client must authenticate again with a new JWT.
* The FE configuration item `enable_rest_bearer_authentication` (default `true`) turns Bearer authentication on the HTTP and Arrow Flight entry points off. It never affects the MySQL protocol, where token logins keep using the `authentication_openid_connect_client` and `authentication_oauth2_client` plugins.
* MySQL connections negotiate an authentication plugin during the handshake. To select JWT independently of the integration order, clients explicitly declare `authentication_openid_connect_client`, as described in the authentication-chain rules above. HTTP and Arrow Flight route Bearer tokens by issuer and audience without a MySQL plugin negotiation. See [Mix LDAP and JWT security integrations](#mix-ldap-and-jwt-security-integrations).
* Every failed HTTP authentication answers `401` with both a `Basic` and a `Bearer` challenge in `WWW-Authenticate`, and does not say which integration refused or why. Use the `authentication_failure_total` and `authentication_failure_reason_total` metrics on the FE to diagnose failures.

## Manage security integrations

### Alter security integration

You can alter the configuration of an existing security integration using the following statement:

```SQL theme={null}
ALTER SECURITY INTEGRATION <security_integration_name> SET
(
    "key"="value"[, ...]
)
```

**Note**

You cannot alter the `type` of a security integration.

### Drop security integration

You can drop an existing security integration using the following statement:

```SQL theme={null}
DROP SECURITY INTEGRATION <security_integration_name>
```

### View security integration

You can view all security integrations in your cluster using the following statement:

```SQL theme={null}
SHOW SECURITY INTEGRATIONS;
```

Example:

```Plain theme={null}
SHOW SECURITY INTEGRATIONS;
+--------+--------+---------+
| Name   | Type   | Comment |
+--------+--------+---------+
| LDAP1  | LDAP   | NULL    |
+--------+--------+---------+
```

| **Parameter** | **Description** |
| - | - |
| Name | The name of the security integration. |
| Type | The type of the security integration. |
| Comment | The description of the security integration. `NULL` is returned when no description is specified for the security integration. |

You can check the details of a security integration using the following statement:

```SQL theme={null}
SHOW CREATE SECURITY INTEGRATION <integration_name>
```

Example:

```Plain theme={null}
SHOW CREATE SECURITY INTEGRATION LDAP1；

+----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Security Integration  | Create Security Integration                                                                                                                                                                                                                                                                                                                                                                              |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| LDAP1                | CREATE SECURITY INTEGRATION LDAP1
    PROPERTIES (
      "type" = "authentication_ldap_simple",
      "authentication_ldap_simple_server_host" = "",
      "authentication_ldap_simple_server_port" = "",
      "authentication_ldap_simple_bind_base_dn" = "",
      "authentication_ldap_simple_user_search_attr" = ""
      "authentication_ldap_simple_bind_root_dn" = "",
      "authentication_ldap_simple_bind_root_pwd" = "",
      "authentication_ldap_simple_ssl_conn_allow_insecure" = "{true | false}",
      "authentication_ldap_simple_ssl_conn_trust_store_path" = "",
      "authentication_ldap_simple_ssl_conn_trust_store_pwd" = "",
      "comment" = ""
)|
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
```

**Note**

`ldap_bind_root_pwd` is masked when SHOW CREATE SECURITY INTEGRATION is executed.

## Connect to the database via a security integration

* For instructions on how to connect to the database via LDAP, see [LDAP Authentication - Connect to the database](/documents/4.2/administration/user_privs/authentication/ldap_authentication.md#connect-from-mysql-client-with-ldap).
* For instructions on how to connect to the database via JWT, see [JSON Web Token Authentication - Connect to the database](/documents/4.2/administration/user_privs/authentication/jwt_authentication.md#connect-from-mysql-client-with-jwt).
* For instructions on how to connect to the database via OAuth 2.0, see [OAuth 2.0 Authentication - Connect to the database](/documents/4.2/administration/user_privs/authentication/oauth2_authentication.md#connect-from-jdbc-client-with-oauth-20).

## See also

* For instructions on how to manually authenticate users via LDAP in the database, see [LDAP Authentication](/documents/4.2/administration/user_privs/authentication/ldap_authentication.md).
* For instructions on how to manually authenticate users via JSON Web Token in the database, see [JSON Web Token Authentication](/documents/4.2/administration/user_privs/authentication/jwt_authentication.md).
* For instructions on how to manually authenticate users via OAuth 2.0 in the database, see [OAuth 2.0 Authentication](/documents/4.2/administration/user_privs/authentication/oauth2_authentication.md).
* For instructions on how to authenticate user groups, see [Authenticate User Groups](/documents/4.2/administration/user_privs/group_provider.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.