Created on 12-10-2024 06:02 PM - edited 12-10-2024 06:04 PM
I need to authenticate to a Kafka Broker using OAuth.
I am looking at the Apache NiFi issues pages and see this URL to add support for SASL/OAUTHBEARER to the Kafka 3 processors which now have an allowable values list of SASL mechanisms - https://issues.apache.org/jira/browse/NIFI-7421
Does anyone know if this will ever be implemented?
Otherwise, does anyone have any list of ideas I could use to achieve this requirement?
Created on 12-18-2024 08:50 AM - edited 12-18-2024 08:52 AM
@drewski7
I have just picked your ticket I hope I can help you resolve this issue if its still unresolved. There are are couple of configurations changes and implementations that have to done.
1. Overview
OAuth allows Kafka clients to obtain access tokens from an external authentication provider like OAuth providers to authenticate with the Kafka broker.
This process involves configuring the Kafka broker, OAuth provider, and Kafka clients.
2. Prerequisites
Set up an OAuth provider (e.g., Keycloak, Okta, etc.) to act as the identity provider (IdP).
Register a new client application for Kafka in the OAuth provider:
Note down the following details:
Step 2: Configure the Kafka Broker
Enable SASL/OAUTHBEARER Authentication:
Edit the Kafka broker configuration (/config/server.properties)
Replace <listener-name> with (SASL_PLAINTEXT, SASL_SSL) as appropriate.
Configure ACLs (Optional):
Restart the Kafka Broker:
Add required dependencies to your Kafka client application:
For Java applications, add the Kafka and OAuth dependencies to your pom.xml or build.gradle.
pom.xml example
2. Configure OAuth in the Kafka Client:
3. Implement Token Retrieval (Optional):
4. Create the Kafka Producer/Consumer:
Use the above configuration to initialize a Kafka producer or consumerProduce and consume messages to verify OAuth-based authentication: