Enable OAuth 2.0/OIDC authentication for Apache Kafka®
Aiven for Apache Kafka® supports OAuth 2.0/OIDC authentication for Kafka clients. Use OAuth 2.0/OIDC authentication to let clients authenticate with tokens issued by an identity provider or by an identity broker that supports Outbound Identity Federation. For AWS IAM, see OAuth 2.0/OIDC with AWS IAM.
Prerequisites
Before you begin, make sure you have:
- An Aiven for Apache Kafka service.
- SASL authentication
enabled on the service. OAuth 2.0/OIDC uses the
OAUTHBEARERSASL mechanism. - Access to an OIDC provider, such as Auth0, Okta, Google Identity Platform, Azure, or another OIDC-compliant provider.
- Configuration details from your OIDC provider:
- JWKS endpoint URL: Required. HTTPS URL to retrieve the JSON Web Key Set, or JWKS.
- Issuer URL or identifier: Required. The expected issuer of the JWT as configured in your OIDC provider settings.
- Audience identifiers: Required. The expected audience of the JWT. For multiple audiences, note each value.
- Subject claim name: Optional. Typically
sub, but this can vary depending on your OIDC provider.
Configuration steps vary by identity provider. See your provider's documentation for JWKS URL, issuer, and audience values.
OAuth 2.0/OIDC authentication works independently of Aiven service users. If you use Aiven ACLs instead of Kafka-native ACLs to control access, create a matching Aiven service user with the same identifier as the OIDC principal. This identifier can be the identity provider's service principal ID. Aiven enforces the ACL only when this matching service user exists. Kafka-native ACLs do not have this requirement. For more information, see Manage access control lists.
Configure OAuth 2.0/OIDC settings
Set kafka.sasl_oauthbearer_jwks_endpoint_url to enable OAUTHBEARER. You must also
set kafka.sasl_oauthbearer_expected_issuer and
kafka.sasl_oauthbearer_expected_audience. Without them, the broker accepts any
validly signed token from the JWKS endpoint, whatever its issuer or audience.
If your service already uses OAuth 2.0/OIDC authentication without an expected issuer
or audience, you must set both values the next time you change any of its user
configuration, including settings unrelated to OIDC. Otherwise, the update is rejected. If
your identity provider can't supply one of the values, see the
unverified options.
To use only OAuth 2.0/OIDC authentication, enable SASL authentication, set
kafka.sasl_oauthbearer_jwks_endpoint_url, the expected issuer and audience, and
disable PLAIN, SCRAM-SHA-256, and SCRAM-SHA-512.
When SASL authentication is enabled, at least one SASL mechanism must be available.
OAUTHBEARER satisfies this requirement when
kafka.sasl_oauthbearer_jwks_endpoint_url is set.
Configure OAuth 2.0/OIDC authentication using one of the following methods.
- Aiven Console
- CLI
-
In the Aiven Console, select your project and choose your Aiven for Apache Kafka service.
-
Click Service settings.
-
Scroll to Advanced configuration and click Configure.
-
In the Advanced configuration window, click Add configuration options.
-
Enable SASL authentication by setting
kafka_authentication_methods.saslto Enabled. -
Configure the JWKS endpoint by setting
kafka.sasl_oauthbearer_jwks_endpoint_urlto your provider's JWKS URL.This enables the
OAUTHBEARERmechanism.PLAIN,SCRAM-SHA-256, andSCRAM-SHA-512remain enabled by default. -
Set the required
kafka.sasl_oauthbearer_expected_issuerandkafka.sasl_oauthbearer_expected_audienceto the values from your OIDC provider. -
Optional: Set
kafka.sasl_oauthbearer_sub_claim_name. See OIDC parameters for details. -
Optional: To use only OAuth 2.0/OIDC authentication, set
kafka_sasl_mechanisms.plain,kafka_sasl_mechanisms.scram_sha_256, andkafka_sasl_mechanisms.scram_sha_512to Disabled. -
Click Save configurations.
To configure OAuth 2.0/OIDC authentication for your Aiven for Apache Kafka service using the Aiven CLI:
Each avn service update that changes OIDC or SASL settings triggers a rolling
restart of Apache Kafka brokers. Combine the -c flags you need in a single command
when applying multiple changes.
-
Get the name of your Aiven for Apache Kafka service:
avn service listNote the
SERVICE_NAMEcorresponding to your Aiven for Apache Kafka service. -
Enable SASL authentication and configure the JWKS endpoint, expected issuer, and expected audience in a single command:
avn service update SERVICE_NAME \-c kafka_authentication_methods.sasl=true \-c kafka.sasl_oauthbearer_jwks_endpoint_url="https://my-jwks-endpoint.example.com/jwks" \-c kafka.sasl_oauthbearer_expected_issuer="https://my-issuer.example.com" \-c kafka.sasl_oauthbearer_expected_audience="my-audience"This enables the
OAUTHBEARERmechanism.PLAIN,SCRAM-SHA-256, andSCRAM-SHA-512remain enabled by default. -
Optional: Add the following flags to the same command:
- To set the subject claim name, add
-c kafka.sasl_oauthbearer_sub_claim_name="sub". - To use only OAuth 2.0/OIDC authentication, add
-c kafka_sasl_mechanisms.plain=false,-c kafka_sasl_mechanisms.scram_sha_256=false, and-c kafka_sasl_mechanisms.scram_sha_512=false.
Do not run these flags as a separate command.
Replace the following:
SERVICE_NAME: name of your Aiven for Apache Kafka service.
- To set the subject claim name, add
For details about the OIDC parameters, see OIDC parameters.
OIDC parameters
Configure the following OIDC parameters:
-
kafka.sasl_oauthbearer_jwks_endpoint_url-
Description: Endpoint for retrieving the JSON Web Key Set, or JWKS, which enables OIDC authentication. Corresponds to the Apache Kafka parameter
sasl.oauthbearer.jwks.endpoint.url. -
Value: Enter the HTTPS JWKS endpoint URL provided by your OIDC provider.
noteStarting with Apache Kafka 4.0, the broker verifies that the JWKS endpoint URL for OAuth authentication matches an entry in the system property
org.apache.kafka.sasl.oauthbearer.allowed.urls. Aiven sets this property from the value ofkafka.sasl_oauthbearer_jwks_endpoint_url. You do not need additional configuration.
-
-
kafka.sasl_oauthbearer_sub_claim_name-
Optional
-
Description: Name of the JWT's subject claim for broker verification. It is typically set to
sub. Corresponds to the Apache Kafka parametersasl.oauthbearer.sub.claim.name. -
Value: Enter
subor the specific claim name provided by your OIDC provider if different.noteThe claim must be a string. Claims that contain arrays, such as
groups, are not supported.
-
-
kafka.sasl_oauthbearer_expected_issuer- Required, unless
kafka.sasl_oauthbearer_allow_unverified_issueris set toTrue - Description: JWT issuer that the broker verifies. Corresponds to the
Apache Kafka parameter
sasl.oauthbearer.expected.issuer. - Value: Enter the issuer URL or identifier provided by your OIDC provider.
- Required, unless
-
kafka.sasl_oauthbearer_expected_audience- Required, unless
kafka.sasl_oauthbearer_allow_unverified_audienceis set toTrue - Description: JWT audience that the broker verifies. Corresponds to the
Apache Kafka parameter
sasl.oauthbearer.expected.audience. - Value: Enter the audience identifiers given by your OIDC provider. If there are multiple audiences, separate them with commas.
- Required, unless
-
kafka.sasl_oauthbearer_allow_unverified_issuer- Optional
- Description: Allows OAuth 2.0/OIDC authentication without setting
kafka.sasl_oauthbearer_expected_issuer. Use this setting only if your identity provider can't supply an issuer. Until Apache Kafka 4.4, the brokers then accept any validly signed token from the JWKS endpoint, whatever its issuer. This exposes the brokers to CVE-2026-110952. - Value: Set to
Trueto skip issuer verification.
-
kafka.sasl_oauthbearer_allow_unverified_audience- Optional
- Description: Allows OAuth 2.0/OIDC authentication without setting
kafka.sasl_oauthbearer_expected_audience. Use this setting only if your identity provider can't supply an audience. Until Apache Kafka 4.4, the brokers then accept any validly signed token from the JWKS endpoint, whatever its audience. This exposes the brokers to CVE-2026-110952. - Value: Set to
Trueto skip audience verification.
In Apache Kafka 3.1.0 to 4.3.x, a broker that uses a JWKS endpoint checks the token signature but not the issuer or audience, unless you set the expected values. The broker accepts any validly signed token from that JWKS endpoint, whatever its issuer or audience. Apache Kafka 4.4.0 fixes this. It refuses to start a broker that uses a JWKS endpoint unless you set both values or explicitly allow unverified ones.
To protect your brokers, set both kafka.sasl_oauthbearer_expected_issuer and
kafka.sasl_oauthbearer_expected_audience. Until Apache Kafka 4.4, setting
kafka.sasl_oauthbearer_allow_unverified_issuer or
kafka.sasl_oauthbearer_allow_unverified_audience to True keeps the brokers exposed
to CVE-2026-110952.
For more information about each corresponding Apache Kafka parameter,
see Apache Kafka documentation on
configuration options starting with sasl.oauthbearer.
Changing OIDC settings triggers a rolling restart of Apache Kafka brokers. As a result, the brokers temporarily operate with different configurations. To reduce operational impact, apply these changes during a maintenance window.
Related pages