<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question NiFi - Support SASL/OAUTHBEARER in Kafka processors in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Support-SASL-OAUTHBEARER-in-Kafka-processors/m-p/398654#M250273</link>
    <description>&lt;P&gt;I need to authenticate to a Kafka Broker using OAuth.&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 -&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/NIFI-7421" target="_blank" rel="noopener"&gt;https://issues.apache.org/jira/browse/NIFI-7421&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Does anyone know if this will ever be implemented?&lt;/P&gt;&lt;P&gt;Otherwise, does anyone have any list of ideas I could use to achieve this requirement?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Dec 2024 02:04:46 GMT</pubDate>
    <dc:creator>drewski7</dc:creator>
    <dc:date>2024-12-11T02:04:46Z</dc:date>
    <item>
      <title>NiFi - Support SASL/OAUTHBEARER in Kafka processors</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Support-SASL-OAUTHBEARER-in-Kafka-processors/m-p/398654#M250273</link>
      <description>&lt;P&gt;I need to authenticate to a Kafka Broker using OAuth.&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 -&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/NIFI-7421" target="_blank" rel="noopener"&gt;https://issues.apache.org/jira/browse/NIFI-7421&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Does anyone know if this will ever be implemented?&lt;/P&gt;&lt;P&gt;Otherwise, does anyone have any list of ideas I could use to achieve this requirement?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 02:04:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Support-SASL-OAUTHBEARER-in-Kafka-processors/m-p/398654#M250273</guid>
      <dc:creator>drewski7</dc:creator>
      <dc:date>2024-12-11T02:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Support SASL/OAUTHBEARER in Kafka processors</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Support-SASL-OAUTHBEARER-in-Kafka-processors/m-p/399029#M250377</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/79092"&gt;@drewski7&lt;/a&gt;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;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.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;1. Overview&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;OAuth allows Kafka clients to obtain access tokens from an external authentication provider like OAuth providers to authenticate with the Kafka broker. &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;This process involves configuring the Kafka broker, OAuth provider, and Kafka clients.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;2. Prerequisites&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Kafka cluster with SASL/OAUTHBEARER enabled.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;An OAuth provider set up to issue access tokens.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Kafka clients that support SASL/OAUTHBEARER.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Required libraries for OAuth integration (e.g. kafka-clients, oauth2-client, or keycloak adapters).&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;3. Procedure&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;H4&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Step 1: Configure the OAuth Provider&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;Set up an OAuth provider (e.g., Keycloak, Okta, etc.) to act as the identity provider (IdP).&lt;/FONT&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;Register a new client application for Kafka in the OAuth provider:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Set up &lt;STRONG&gt;client ID&lt;/STRONG&gt; and &lt;STRONG&gt;client secret&lt;/STRONG&gt; for Kafka clients.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Configure scopes, roles, or claims required for authorization.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Enable grant types like &lt;STRONG&gt;Client Credentials&lt;/STRONG&gt; or &lt;STRONG&gt;Password&lt;/STRONG&gt; (depending on your use case).&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;Note down the following details:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Authorization Server URL (e.g.&lt;A href="https://authl" target="_blank"&gt;https://authl&lt;/A&gt;&lt;SPAN&gt;ogin.northwind.com/&lt;/SPAN&gt;token).&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Client ID and Client Secret.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Step 2: Configure the Kafka Broker&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Enable SASL/OAUTHBEARER Authentication&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;Edit the Kafka broker configuration (/config/server.properties)&lt;/FONT&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;LI-SPOILER&gt;&lt;FONT size="2"&gt;sasl.enabled.mechanisms=OAUTHBEARER&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;listener.name.&amp;lt;listener-name&amp;gt;.oauthbearer.sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required \&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;oauth.token.endpoint.uri="&lt;A href="https://auth.example.com/token" target="_blank" rel="noopener"&gt;https://auth.example.com/token&lt;/A&gt;" \&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;oauth.client.id="kafka-broker-client-id" \&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;oauth.client.secret="kafka-broker-client-secret" \&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;oauth.scope="kafka-scope";&lt;/FONT&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&lt;FONT size="2"&gt;Replace &amp;lt;listener-name&amp;gt; with (SASL_PLAINTEXT, SASL_SSL) as&amp;nbsp; appropriate.&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Configure ACLs (Optional)&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;If using authorization, configure ACLs to grant specific permissions to authenticated users.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Restart the Kafka Broker&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Restart the Kafka broker to apply the changes&lt;/FONT&gt;&lt;BR /&gt;&lt;LI-SPOILER&gt;&lt;FONT size="2"&gt;sudo systemctl restart kafka&lt;/FONT&gt;&lt;/LI-SPOILER&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H4&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Step 3: Configure the Kafka Client&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;Add required dependencies to your Kafka client application:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;For Java applications, add the Kafka and OAuth dependencies to your pom.xml or build.gradle.&lt;/FONT&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;FONT size="2"&gt;pom.xml example&lt;/FONT&gt;&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;FONT size="2"&gt;&amp;lt;dependency&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;groupId&amp;gt;org.apache.kafka&amp;lt;/groupId&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;artifactId&amp;gt;kafka-clients&amp;lt;/artifactId&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;version&amp;gt;3.0.0&amp;lt;/version&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;/dependency&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;dependency&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;groupId&amp;gt;com.nimbusds&amp;lt;/groupId&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;artifactId&amp;gt;oauth2-oidc-sdk&amp;lt;/artifactId&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;version&amp;gt;9.4&amp;lt;/version&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;lt;/dependency&amp;gt;&lt;/FONT&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;2. Configure OAuth in the Kafka Client:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Specify the SASL mechanism and the OAuth token endpoint in the client configuration&lt;/FONT&gt;&lt;BR /&gt;&lt;LI-SPOILER&gt;&lt;FONT size="2"&gt;Properties props = new Properties();&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;props.put("bootstrap.servers", "broker1:9092,broker2:9092");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;props.put("security.protocol", "SASL_SSL");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;props.put("sasl.mechanism", "OAUTHBEARER");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;props.put("sasl.jaas.config", &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;"org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required " +&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;"oauth.token.endpoint.uri=\"&lt;A href="https://auth.example.com/token\" target="_blank" rel="noopener"&gt;https://auth.example.com/token\&lt;/A&gt;" " +&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;"oauth.client.id=\"kafka-client-id\" " +&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;"oauth.client.secret=\"kafka-client-secret\";");&lt;/FONT&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;3. Implement Token Retrieval (Optional)&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Use an external tool or library to retrieve and manage tokens if you need a custom implementation.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-SPOILER&gt;&lt;FONT size="2"&gt;curl -X POST -d "grant_type=client_credentials&amp;amp;client_id=kafka-client-id&amp;amp;client_secret=kafka-client-secret" \&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;A href="https://auth.example.com/token" target="_blank" rel="noopener"&gt;https://auth.example.com/token&lt;/A&gt;&lt;/FONT&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;4. Create the Kafka Producer/Consumer&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size="2"&gt;Use the above configuration to initialize a Kafka producer or consumer&lt;/FONT&gt;&lt;BR /&gt;&lt;LI-SPOILER&gt;&lt;FONT size="2"&gt;KafkaProducer&amp;lt;String, String&amp;gt; producer = new KafkaProducer&amp;lt;&amp;gt;(props);&lt;/FONT&gt;&lt;/LI-SPOILER&gt;&lt;H4&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Step 4: Test the Authentication&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;Produce and consume messages to verify OAuth-based authentication:&lt;/FONT&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;LI-SPOILER&gt;&lt;FONT size="2"&gt;kafka-console-producer.sh --broker-list &amp;lt;broker-address&amp;gt; --topic &amp;lt;topic-name&amp;gt; --producer.config &amp;lt;client-config&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;kafka-console-consumer.sh --bootstrap-server &amp;lt;broker-address&amp;gt; --topic &amp;lt;topic-name&amp;gt; --consumer.config &amp;lt;client-config&amp;gt;&lt;/FONT&gt;&lt;/LI-SPOILER&gt; &lt;FONT size="2"&gt;Ensure logs indicate successful authentication using SASL/OAUTHBEARER.&lt;/FONT&gt;&lt;BR /&gt;&lt;H4&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Step 5: Monitor and Debug&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Check Kafka broker logs for errors related to OAuth authentication.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Verify token expiration and renewal mechanisms.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Ensure the OAuth provider is reachable from the Kafka brokers and clients.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Happy Hadooping I hope the above steps helps in the diagnosis and resolution of you Kafka OAuth issue&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 16:52:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Support-SASL-OAUTHBEARER-in-Kafka-processors/m-p/399029#M250377</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2024-12-18T16:52:14Z</dc:date>
    </item>
  </channel>
</rss>

