Skip to main content

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 OAUTHBEARER SASL 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.

Note

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.

Important

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.

Note

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.

  1. In the Aiven Console, select your project and choose your Aiven for Apache Kafka service.

  2. Click Service settings.

  3. Scroll to Advanced configuration and click Configure.

  4. In the Advanced configuration window, click Add configuration options.

  5. Enable SASL authentication by setting kafka_authentication_methods.sasl to Enabled.

  6. Configure the JWKS endpoint by setting kafka.sasl_oauthbearer_jwks_endpoint_url to your provider's JWKS URL.

    This enables the OAUTHBEARER mechanism. PLAIN, SCRAM-SHA-256, and SCRAM-SHA-512 remain enabled by default.

  7. Set the required kafka.sasl_oauthbearer_expected_issuer and kafka.sasl_oauthbearer_expected_audience to the values from your OIDC provider.

  8. Optional: Set kafka.sasl_oauthbearer_sub_claim_name. See OIDC parameters for details.

  9. Optional: To use only OAuth 2.0/OIDC authentication, set kafka_sasl_mechanisms.plain, kafka_sasl_mechanisms.scram_sha_256, and kafka_sasl_mechanisms.scram_sha_512 to Disabled.

  10. Click Save configurations.

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.

      note

      Starting 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 of kafka.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 parameter sasl.oauthbearer.sub.claim.name.

    • Value: Enter sub or the specific claim name provided by your OIDC provider if different.

      note

      The 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_issuer is set to True
    • 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.
  • kafka.sasl_oauthbearer_expected_audience

    • Required, unless kafka.sasl_oauthbearer_allow_unverified_audience is set to True
    • 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.
  • 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 True to 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 True to skip audience verification.
Warning

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.

warning

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