Configure Microsoft Entra ID as Your Identity Provider for OAuth in Confluent Platform
Set up Microsoft Entra ID as an OAuth 2.0 or OIDC identity provider for Confluent Platform. Register an application to get a client ID and secret, and then use them to authenticate with the standard OAuth 2.0 client credentials grant.
Note
Your Kafka clients might run on Azure compute, such as a VM, Azure Kubernetes Service, or an Azure Container Instance. If so, and you want to avoid managing a static client secret, use Azure User-Assigned Managed Identity (UAMI) instead. UAMI lets Azure supply short-lived Microsoft Entra ID tokens automatically. For details, see Configure Azure User Assigned Managed Identity OAuth for Confluent Platform.
A Microsoft Entra ID setup for Confluent Platform can use up to three application registrations. Register only the ones that you need:
Application |
Used for |
Instructions |
|---|---|---|
Resource |
Represents your cluster. Brokers and services validate the tokens that are issued for it. |
|
Client |
Each producer, consumer, or service that connects with the client credentials grant |
|
SSO |
User sign-in to Control Center and the Confluent CLI |
Configure Confluent Control Center SSO with Microsoft Entra ID |
Prerequisites
Confluent Platform 7.7 or later
Required Microsoft Entra ID tenant permissions:
To register an application, see Register an application.
To create and assign app roles for role-based access control (RBAC), see Add app roles and get them from a token.
Step 1: Register an application in Microsoft Entra ID
Register an application to represent your Confluent Platform cluster. This is the resource application. Client applications request tokens scoped to this resource application to authenticate to Confluent Platform.
In the Microsoft Entra admin center, register a new application, entering a name such as
cp-kafka-cluster. For more information, see Register an application.On the application’s Overview page, record the values of the following fields. You need them in Step 2: Get Microsoft Entra ID endpoint values.
Application (client) ID
Directory (tenant) ID
Enable v2.0 access tokens. Confluent Platform validates tokens issued by the v2.0 endpoint. Go to the Manifest page and set
requestedAccessTokenVersionto2:"api": { "requestedAccessTokenVersion": 2 }
For details, see Configure the application manifest.
On the Expose an API page, set the Application ID URI. Accept the default value, for example
api://<application_client_id>, or enter a custom URI, and record the value. Clients use this value in the token scope. In v2.0 access tokens, theaudclaim is always the Application (client) ID of this application, regardless of the Application ID URI. For instructions, see Configure an application to expose a web API.Create a client secret for the application that uses the client credentials grant to authenticate to Confluent Platform. Go to the Certificates & secrets page, open the Client secrets tab, and click New client secret. Record the value shown in the Value field immediately. It isn’t shown again. For instructions, see Add a client secret.
Tip
For a production deployment, register a separate application for each client or service that authenticates to Confluent Platform, rather than reusing the resource application’s credentials. Registering the same application as both resource and client, as shown in this topic, is intended to get a single client working end-to-end quickly. For instructions, see Register a separate client application.
(Optional) To authorize with RBAC based on Microsoft Entra ID app roles instead of group membership, add app roles on the App roles page and set Allowed member types to Applications. Then grant the roles to the client application, as described in Register a separate client application.
Important
In the client credentials grant, Microsoft Entra ID doesn’t evaluate group-based app role assignments when building the
rolesclaim. Grant app roles directly to the application, not through a group. For the full group- and role-claim mapping behavior, including a known Microsoft Entra ID group overage limitation, see Use RBAC with OAuth-OIDC in Confluent Platform Clusters and Microsoft Entra ID group claim behavior and overage.
Step 2: Get Microsoft Entra ID endpoint values
Using the Directory (tenant) ID, Application (client) ID, client secret, and Application ID URI from step 1, assemble the following values.
Value |
How to derive it |
|---|---|
Issuer ( |
|
JWKS endpoint |
|
Token endpoint |
|
Expected audience ( |
The Application (client) ID of the resource application, for
example |
Scope |
The Application ID URI followed by |
Tip
You can confirm these values, except the client secret and scope, by
fetching the tenant’s OIDC discovery document at
https://login.microsoftonline.com/<tenant_id>/v2.0/.well-known/openid-configuration.
Step 3: Configure Confluent Server brokers
Configure your Confluent Server broker listener for OAuth authentication, substituting the values from step 2:
listener.name.external.sasl.enabled.mechanisms=OAUTHBEARER
listener.name.external.sasl.oauthbearer.jwks.endpoint.url=https://login.microsoftonline.com/<tenant_id>/discovery/v2.0/keys
listener.name.external.sasl.oauthbearer.expected.issuer=https://login.microsoftonline.com/<tenant_id>/v2.0
listener.name.external.sasl.oauthbearer.expected.audience=<application_client_id>
listener.name.external.principal.builder.class=io.confluent.kafka.security.authenticator.OAuthKafkaPrincipalBuilder
confluent.oauth.groups.claim.name=groups
Also add a callback handler and JAAS configuration to the listener.
Without RBAC:
listener.name.external.oauthbearer.sasl.server.callback.handler.class=org.apache.kafka.common.security.oauthbearer.OAuthBearerValidatorCallbackHandler
listener.name.external.oauthbearer.sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required;
With RBAC, add the following. Without this callback handler, most Confluent Control Center API calls fail:
listener.name.external.oauthbearer.sasl.server.callback.handler.class=io.confluent.kafka.server.plugins.auth.token.CompositeBearerValidatorCallbackHandler
listener.name.external.oauthbearer.sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required unsecuredLoginStringClaim_sub="thePrincipalName" publicKeyPath="<public_key_path>";
For the full set of required and optional broker settings, including interbroker communication and KRaft mode, see Configure Confluent Server Brokers for OAuth Authentication in Confluent Platform.
Choose the claim that identifies the principal
Confluent Platform uses the sub claim as the principal name by default. The
principal name is the value you use to create role bindings. In
Microsoft Entra ID, the sub claim is a pairwise identifier unique to
the application. It isn’t the application’s client ID. If you keep the
sub claim, decode a token to find the value for role bindings. For
details, see Step 5: Verify your configuration.
In v2.0 access tokens, Microsoft Entra ID also provides an azp claim that
contains the client ID of the application that requested the token. Use the
azp claim only when clients connect using the client credentials grant. In
a token issued on behalf of a user, the azp claim is still the
application’s client ID, so every user of that application maps to the same
principal. To use the client ID as the principal name, add the following
properties to the broker configuration:
# Broker listener
listener.name.external.sasl.oauthbearer.sub.claim.name=azp
# Metadata Service (MDS)
confluent.metadata.server.oauthbearer.sub.claim.name=azp
Use the same claim name for the broker and Metadata Service (MDS). The principal in your role bindings is the value of that claim. For more information, see Access token claims reference in the Microsoft Entra ID documentation.
Choose the claim that lists roles or groups
Set the claim that holds the groups or roles for a principal on both the broker and Metadata Service (MDS):
confluent.oauth.groups.claim.name=<groups_or_roles>
confluent.metadata.server.oauthbearer.groups.claim.name=<groups_or_roles>
Use one of the following values:
To authorize by the security groups that the client’s service principal belongs to, use
groups. SetgroupMembershipClaimstoSecurityGroupin the resource application’s manifest so that Microsoft Entra ID emits the claim. The claim lists group object IDs, not group names, so create role bindings forGroup:<group_object_id>. For groups of users who sign in with SSO, see Configure Confluent Control Center SSO with Microsoft Entra ID.To authorize service principals by Microsoft Entra ID app role, use
roles. For details, see Use RBAC with OAuth-OIDC in Confluent Platform Clusters.
Step 4: Configure Kafka clients
Configure your Kafka clients to request a token from Microsoft Entra ID using the client credentials grant, substituting the Application (client) ID and client secret from step 1 and the token endpoint and scope from step 2:
sasl.mechanism=OAUTHBEARER
security.protocol=SASL_SSL
sasl.login.callback.handler.class=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginCallbackHandler
sasl.oauthbearer.token.endpoint.url=https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token
sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required \
clientId="<application_client_id>" \
clientSecret="<client_secret>" \
scope="api://<application_client_id>/.default";
For the complete client configuration reference, including non-Java clients, see Configure Kafka clients.
Step 5: Verify your configuration
Request a token directly from the token endpoint to confirm the application registration is correct, replacing
<tenant_id>,<application_client_id>, and<client_secret>:curl -X POST "https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token" \ -d "grant_type=client_credentials" \ -d "client_id=<application_client_id>" \ -d "client_secret=<client_secret>" \ -d "scope=api://<application_client_id>/.default"
Decode the returned
access_tokenat jwt.io and confirm thatissmatcheshttps://login.microsoftonline.com/<tenant_id>/v2.0andaudmatches the Application (client) ID from step 1.If
issishttps://sts.windows.net/<tenant_id>/, Microsoft Entra ID issued a v1.0 token. Check therequestedAccessTokenVersionsetting from step 1.With the client properties from step 4 saved to a file (for example,
oauth-client.properties), test end-to-end connectivity, replacing<host>. This step assumes CONFLUENT_HOME is set:$CONFLUENT_HOME/bin/kafka-console-producer \ --bootstrap-server <host>:9095 \ --topic test-topic \ --producer.config oauth-client.properties
Register a separate client application
For a production deployment, register a separate application for each client or service that connects to Confluent Platform, such as a producer, a consumer, or a Kafka Connect worker. Each client application has its own client ID and secret, and is granted only the app roles that it needs from the resource application. For instructions on registering the resource application, see Register an application in Microsoft Entra ID.
In the resource application, create the roles to grant to clients. On the App roles page, click Create app role and set Allowed member types to Applications. The Value you enter appears in the
rolesclaim of tokens issued to clients that are granted the role. For instructions, see Add app roles and get them from a token.Register a new application for the client, as described in Register an application. The client application doesn’t need a redirect URI. Record its Application (client) ID.
On the client application’s Certificates & secrets page, create a client secret and record the value, which isn’t shown again.
On the client application’s API permissions page, click Add a permission, select the My APIs tab, and then select the resource application. Under Application permissions, select the roles that the client needs, and then click Add permissions.
Note
Both the resource application and the client application must have an owner. Otherwise, the resource application isn’t listed on the My APIs tab.
Click Grant admin consent for <tenant_name>, and then confirm. Because these are application permissions, an administrator must grant consent. Confirm that the Status column shows Granted for <tenant_name>.
Configure the client with its own client ID and secret. The scope refers to the resource application:
sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required \ clientId="<client_application_client_id>" \ clientSecret="<client_application_secret>" \ scope="api://<application_client_id>/.default";
Here,
<application_client_id>is the client ID of the resource application.To verify the roles, request a token and decode it, as described in Verify your configuration. Use the client application’s ID and secret. The
rolesclaim lists the granted roles, and theazpclaim contains the client application’s client ID:{ "aud": "<application_client_id>", "iss": "https://login.microsoftonline.com/<tenant_id>/v2.0", "azp": "<client_application_client_id>", "roles": ["<app_role_value>"], "ver": "2.0" }
To authorize the client with RBAC, set
confluent.oauth.groups.claim.nameandconfluent.metadata.server.oauthbearer.groups.claim.nametoroles, and create role bindings forGroup:<app_role_value>. For details, see Use RBAC with OAuth-OIDC in Confluent Platform Clusters.
Deploy the configuration with Ansible
If you deploy with Ansible Playbooks for Confluent Platform, set the equivalent variables in your
inventory file instead of editing the properties files. The following example
enables OAuth and RBAC with the values from this topic. It uses the azp
claim as the principal and the roles claim for authorization of service
principals:
all:
vars:
rbac_enabled: true
auth_mode: oauth
oauth_superuser_client_id: <application_client_id>
oauth_superuser_client_password: <client_secret>
oauth_sub_claim: azp
oauth_groups_claim: roles
oauth_token_uri: https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token
oauth_issuer_url: https://login.microsoftonline.com/<tenant_id>/v2.0
oauth_jwks_uri: https://login.microsoftonline.com/<tenant_id>/discovery/v2.0/keys
oauth_expected_audience: <application_client_id>
# Scope that clients and services request for tokens.
oauth_groups_scope: api://<application_client_id>/.default
# Optional. Required only if the identity provider uses a custom
# certificate.
oauth_idp_cert_path: <path_to_idp_certificate>
# Client credentials for each component. These variables don't default
# to the superuser credentials, so set each one to the client ID and
# secret of an application that you registered for that component.
schema_registry_oauth_user: <schema_registry_client_id>
schema_registry_oauth_password: <schema_registry_client_secret>
kafka_connect_oauth_user: <connect_client_id>
kafka_connect_oauth_password: <connect_client_secret>
ksql_oauth_user: <ksqldb_client_id>
ksql_oauth_password: <ksqldb_client_secret>
kafka_rest_oauth_user: <rest_proxy_client_id>
kafka_rest_oauth_password: <rest_proxy_client_secret>
kafka_connect_replicator_oauth_user: <replicator_client_id>
kafka_connect_replicator_oauth_password: <replicator_client_secret>
control_center_next_gen_oauth_user: <c3_client_id>
control_center_next_gen_oauth_password: <c3_client_secret>
The oauth_groups_scope variable sets the scope that Confluent Platform components request
when they get tokens to authenticate to each other. For Microsoft Entra ID, set
it to api://<application_client_id>/.default.
To also enable Control Center and Confluent CLI single sign-on with Ansible, see Deploy the configuration with Ansible.
For the complete list of authentication variables, see Configure Authentication for Confluent Platform with Ansible Playbooks.