Configuring Apache Kafka OAuth connectivity in Flow Designer
Cloudera Data Flow connects Apache NiFi flows in Flow Designer to OAuth-secured Apache Kafka clusters in Cloudera Streams Messaging on Cloudera Anywhere Cloud through TLS and OAuth controller services.
Apache Kafka clusters deployed with Cloudera Streams Messaging in Cloudera Anywhere Cloud use OAuth authentication over TLS/SSL
(SASL_SSL with the OAUTHBEARER mechanism) for
external client access. To connect an Apache NiFi flow in Flow Designer to a Kafka
cluster, you obtain OAuth client credentials from Anywhere Cloud Console,
download the Kafka client configuration bundle from Cloudera Surveyor, build a single PKCS12
truststore from the bundled CA certificates, supply the truststore to your draft, and
configure controller services for TLS, OAuth token retrieval, and Kafka broker
connectivity.
Principal binding and Apache Ranger authorization
The Anywhere Cloud Console user that you log in as when generating OAuth client credentials determines what your NiFi flow is authorized to access in Kafka. Client credentials are permanently bound to that user's principal. When a NiFi processor connects to Kafka, Apache Ranger evaluates authorization policies against this bound principal instead of a separate client identity.
Ensure that the user account used to generate credentials exists in Apache Ranger and
is assigned to the required policies in the csm-kafka service. For
production data flows, Cloudera recommends logging in to Anywhere Cloud Console with a dedicated identity provider account
configured with only the Ranger permissions that your flow requires.
Options for supplying the PKCS12 truststore
You can provide the PKCS12 truststore file
(truststore.p12) and truststore password to your flow draft
by using either of the following approaches:
- Shared parameter group
- Create a shared parameter group in
Shared Parameter Groups containing truststore.p12 as a file parameter and the truststore password as a sensitive parameter, and then import the group into your flow draft. Uploading file parameters to a shared parameter group does not require a running test session, and you can reuse the group across multiple flow drafts and deployments.
- Draft parameters in an active test session
- Start a test session in Flow Designer, convert Truststore
Filename on
StandardRestrictedSSLContextServiceto a draft parameter, and upload truststore.p12 directly. Flow Designer requires an active test session to upload file-type draft parameters. Use this option when you already have a running test session to develop and validate your flow with live data without creating a shared resource.
Prerequisites
Ensure that your environment meets the following prerequisites before configuring Kafka connectivity in Flow Designer:
- Cloudera Data Flow is deployed in Cloudera Anywhere Cloud, and your user account has the
cdf-flow-adminrole assigned for that instance. - You have prepared your Flow Designer draft for one of the two options for adding
the truststore:
- Shared parameter group option – You have created a flow draft in Flow Designer (an active test session is optional unless you want to enable controller services and validate the flow with live data). For instructions, see Creating a new draft.
- Test session option – You have created a flow draft with an active test session in Flow Designer so that you can upload the truststore file directly as a draft parameter. For instructions, see Starting a test session.
- Cloudera Streams Messaging is deployed and integrated with Cloudera Unified Data Fabric. For deployment instructions, see Deploying Cloudera Streams Messaging.
- Your Anywhere Cloud Console user account is assigned to the
required Apache Ranger policies in the
csm-kafkaservice, including Describe permission on the cluster resource and Publish or Consume permissions on target topics. - You have access to a Bash-compatible shell environment with the Java keytool utility.
Configuration workflow
Connecting a NiFi flow in Flow Designer to an OAuth-secured Kafka cluster involves the following tasks:
- Generate an OAuth
client_idandclient_secretpair from Anywhere Cloud Console. For instructions, see Access keys and API tokens. - Download the Kafka client configuration bundle from Cloudera Surveyor to obtain the CA certificates and broker connection details.
- Combine the downloaded PEM certificates into a single
PKCS12truststore file (truststore.p12) using keytool. - If you are using the shared parameter group scenario, create a shared parameter group containing truststore.p12 and a sensitive truststore password parameter, and import the group into your flow draft. Skip this step if you are uploading truststore.p12 directly in an active test session.
- Configure a
StandardRestrictedSSLContextServicecontroller service by referencing your imported shared parameter group or uploading truststore.p12 in an active test session. - Configure a
StandardOauth2AccessTokenProvidercontroller service to retrieve OAuth access tokens. - Configure a
Kafka3ConnectionServicecontroller service that references both the token provider and SSL context services. - Reference the
Kafka3ConnectionServicein your Kafka processors, such asPublishKafkaorConsumeKafka.
Downloading Apache Kafka client truststore certificates
Download the Apache Kafka client configuration bundle from Cloudera Surveyor to obtain the CA certificates and broker connection properties required in Cloudera Data Flow Flow Designer.
Cloudera Surveyor provides a downloadable client configuration bundle for each monitored Kafka cluster. The bundle includes CA certificate files (kafka-ca.crt and oauth-ca.crt) and an external.properties file containing broker addresses and the OAuth token endpoint URL.
Because Apache NiFi processors manage Kafka properties through controller services, you do not pass external.properties directly to NiFi. Instead, you use the CA certificates to build a truststore and copy the broker and token endpoint values from external.properties into your Flow Designer controller services.
To view your Kafka cluster in Cloudera Surveyor, your logged-in
Anywhere Cloud Console user must be included in the Apache Ranger
access policies for the csm-kafka service, including
Describe permission on the cluster resource.
- Cloudera Streams Messaging is deployed with Cloudera Surveyor in Cloudera Anywhere Cloud.
- Your logged-in Anywhere Cloud Console user has Apache Ranger
Describe permission on the Kafka cluster resource in
the
csm-kafkaservice.
-
Open Cloudera Surveyor from Anywhere Cloud Console.
- In Anywhere Cloud Console, navigate to .
- Select the entry for your Cloudera Surveyor instance.
-
In the Endpoints table, click the URL in the
surveyorLandingPagerow to open the Cloudera Surveyor UI.
-
Download the client configuration bundle from Cloudera Surveyor.
Creating a PKCS12 truststore file
Combine the downloaded Apache Kafka and OAuth CA certificates into a single PKCS12 truststore file using the Java keytool utility for TLS connections in Cloudera Data Flow.
In Cloudera Streams Messaging on Cloudera Anywhere Cloud, the
OAuth server (central Apache Knox) and the Kafka brokers use different certificate
authorities (CAs). Importing both PEM certificates
(kafka-ca.crt and oauth-ca.crt) from
the Cloudera Surveyor client configuration bundle into a
single PKCS12 truststore file (truststore.p12)
enables one SSL context service in Flow Designer to validate TLS connections to both
endpoints.
- You extracted kafka-ca.crt and oauth-ca.crt from the Cloudera Surveyor client configuration bundle.
- The Java keytool utility is installed in your local shell environment.
If you prefer to upload truststore.p12 directly as a draft parameter during an active test session, proceed to Creating an SSL context service.
Creating a shared parameter group for the PKCS12 truststore
Create a shared parameter group with your PKCS12 truststore file and sensitive password to supply TLS truststore credentials to Cloudera Data Flow drafts without a test session.
Perform this task if you want to supply truststore.p12 and its password to Flow Designer through a shared parameter group instead of uploading the file directly in an active test session. Shared parameter groups let you upload file-type parameters without starting a test session and reuse the same truststore across multiple flow drafts and deployments.
If you prefer to upload truststore.p12 directly as a draft parameter during an active test session, skip this task and proceed to configuring the SSL context service.
- You created truststore.p12 and recorded its truststore password.
- Your user account has the
cdf-flow-adminrole assigned (orcdf-adminorcdf-deployment-adminif you are creating the parameter group without importing it to a flow draft). - You created a flow draft in Cloudera Data Flow Flow Designer.
Creating an SSL context service
Configure a StandardRestrictedSSLContextService controller service in Cloudera Data Flow Flow Designer to trust your Apache Kafka and OAuth server CA certificates.
TLS-enabled controller services and processors in Apache NiFi require an SSL context
service to supply truststores and keystores. You configure
StandardRestrictedSSLContextService with your
truststore.p12 file and truststore password either by
referencing parameters from an imported shared parameter group or by converting the
properties to draft parameters in an active test session.
- You created a single
PKCS12truststore file (truststore.p12) and recorded its truststore password. - You opened your flow draft in Cloudera Data Flow Flow Designer
and completed one of the following prerequisites:
- You imported the shared parameter group containing the truststore.p12 file parameter and sensitive truststore password parameter into your draft.
- You started an active test session in your draft so that you can upload truststore.p12 directly when converting Truststore Filename to a draft parameter.
Creating an OAuth2 access token provider service
Configure a StandardOauth2AccessTokenProvider controller service in Cloudera Data Flow Flow Designer to retrieve OAuth bearer tokens for Apache Kafka client authentication.
The StandardOauth2AccessTokenProvider controller service authenticates
against the Anywhere Cloud Console OAuth token endpoint using your
client_id and client_secret credentials and
supplies bearer tokens to the Kafka connection service.
- You generated and recorded an OAuth
client_idandclient_secretpair from Anywhere Cloud Console. For instructions, see Access keys and API tokens. - You extracted external.properties from the Cloudera Surveyor client configuration bundle.
- You created and configured the
StandardRestrictedSSLContextServicecontroller service in your draft (and enabled it if you have an active test session).
Creating a Kafka3ConnectionService for OAuth authentication
Configure a Kafka3ConnectionService controller service in Cloudera Data Flow Flow Designer to connect Apache NiFi processors to an OAuth-secured Apache Kafka cluster.
Apache Kafka processors in Flow Designer delegate broker connections, TLS encryption,
and OAuth authentication to a Kafka3ConnectionService controller
service. This service combines your Kafka bootstrap server address with the
StandardOauth2AccessTokenProvider and
StandardRestrictedSSLContextService instances.
- You extracted external.properties from the Cloudera Surveyor client configuration bundle.
- You created and configured both
StandardRestrictedSSLContextServiceandStandardOauth2AccessTokenProviderin your draft (and enabled them if you have an active test session).
Configuring Apache Kafka processors to use the connection service
Configure Apache Kafka processors such as PublishKafka on the Cloudera Data Flow Flow Designer canvas to authenticate using your Kafka3ConnectionService controller service.
After you configure and enable Kafka3ConnectionService, you can
reference it in Apache Kafka processors such as PublishKafka or
ConsumeKafka on the Flow Designer canvas.
- You created and configured the
Kafka3ConnectionServicecontroller service in your Flow Designer draft (and enabled it if you have an active test session).
