Skip to content

Commit 4aec91a

Browse files
pacostasAedinC
andauthored
Nodejs kafka tutorial - Run through - support for oauthbearer token (#600)
* docs: adding instructions for permissions on kafka topic in nodejs example * docs: instructions for enable oauthbearer authentication mechanism * Update docs/kafka/nodejs-kafka/README.adoc Co-authored-by: AedinC <aecollin@redhat.com> * Update docs/kafka/nodejs-kafka/README.adoc Co-authored-by: AedinC <aecollin@redhat.com> * Update docs/kafka/nodejs-kafka/README.adoc Co-authored-by: AedinC <aecollin@redhat.com> * Update docs/kafka/nodejs-kafka/README.adoc Co-authored-by: AedinC <aecollin@redhat.com> * Update docs/kafka/nodejs-kafka/README.adoc Co-authored-by: AedinC <aecollin@redhat.com> * Update docs/kafka/nodejs-kafka/README.adoc Co-authored-by: AedinC <aecollin@redhat.com> * Update docs/kafka/nodejs-kafka/README.adoc Co-authored-by: AedinC <aecollin@redhat.com> * Apply suggestions from code review Co-authored-by: AedinC <aecollin@redhat.com> * docs: Adding env variables on rhoas.env to connect with oauthbearer * docs: Removing instructions for managing access and adding reference url * Apply suggestions from code review Co-authored-by: AedinC <aecollin@redhat.com>
1 parent d604112 commit 4aec91a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

docs/kafka/nodejs-kafka/README.adoc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ endif::[]
102102
* You have a running Kafka instance in {product-kafka} (see {base-url}{getting-started-url-kafka}[Getting started with {product-long-kafka}^]).
103103
* https://github.com/git-guides/[Git^] is installed.
104104
* You have an IDE such as https://www.jetbrains.com/idea/download/[IntelliJ IDEA^], https://www.eclipse.org/downloads/[Eclipse^], or https://code.visualstudio.com/Download[Visual Studio Code^].
105-
* https://nodejs.org/en/download/[Node.js 14^] is installed. The https://github.com/blizzard/node-rdkafka[node-rdkafka^] client can't run on later versions.
105+
* https://nodejs.org/en/download/[Node.js 14^] or later is installed.
106106

107107
NOTE: The example Node.js application in this quick start uses the https://kafka.js.org/[KafkaJS^] client by default. If you want to use the https://github.com/blizzard/node-rdkafka[node-rdkafka^] client, you must install some development tools locally on your computer or use a container runtime such as Podman or Docker to run a specified container image and configure a development environment. To learn more, see the https://github.com/nodeshift-starters/reactive-example/tree/node-rdkafka#node-rdkafka-and-kafkajs[documentation] for the example Node.js application.
108108

@@ -158,22 +158,22 @@ In this task, you'll create a new configuration file called `rhoas.env`. In the
158158
ifndef::qs[]
159159
* You have the bootstrap server endpoint for your Kafka instance. To get the server endpoint, select your Kafka instance in the {product-kafka} {service-url-kafka}[web console^], select the options icon (three vertical dots), and click *Connection*.
160160
* You have the generated credentials for your service account. To reset the credentials, use the {service-accounts-url}[Service Accounts^] page in the *Application Services* section of the Red Hat Hybrid Cloud Console.
161-
* You've set the permissions for your service account to access the Kafka instance resources. To verify the current permissions, select your Kafka instance in the {product-kafka} web console and use the *Access* page to find your service account permission settings.
162161
endif::[]
163162

164163
.Procedure
165164

166165
. In your IDE, create a new file. Save the file with the name `rhoas.env`, at the root level of the `reactive-example` directory for the cloned repository.
167166

168-
. In the `rhoas.env` file, add the lines shown in the example. These lines set the bootstrap server and client credentials as environment variables to be used by the Node.js application.
167+
. In the `rhoas.env` file, set the SASL authentication mechanism and the Kafka instance client credentials as shown in the following configuration. Replace the client ID and client secret values with your own credential information. The configuration uses SASL/OAUTHBEARER authentication, which is the recommended authentication mechanism to use in {product-kafka}.
169168
+
170169
.Setting environment variables in the rhoas.env file
171-
[source,subs="+quotes"]
170+
[source,subs="+attributes,+quotes"]
172171
----
173172
KAFKA_HOST=__<bootstrap_server>__
174173
RHOAS_SERVICE_ACCOUNT_CLIENT_ID=__<client_id>__
175174
RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET=__<client_secret>__
176-
KAFKA_SASL_MECHANISM=plain
175+
KAFKA_SASL_MECHANISM=oauthbearer
176+
RHOAS_TOKEN_ENDPOINT_URL={sso-token-url}
177177
----
178178
ifdef::qs[]
179179
+
@@ -185,8 +185,6 @@ The values are described as follows:
185185
* *client_secret*: A client credential generated when you create a service account in {product-kafka}. You're prompted to copy and store this credential when you create the service account.
186186
--
187187
endif::[]
188-
+
189-
In this case, observe that the Node.js application uses the SASL/PLAIN authentication method (that is, the value of `KAFKA_SASL_MECHANISM` is set to `plain`). This means that the application uses only the client ID and client secret to authenticate with the Kafka instance. The application doesn't require an authentication token.
190188

191189
. Save the `rhoas.env` file.
192190

@@ -244,6 +242,7 @@ In this task, you'll run the following components of the Node.js application:
244242
.Prerequisites
245243
* You've configured the Node.js example application to connect to a Kafka instance.
246244
* You've created the `countries` topic.
245+
* You've set permissions for your service account to produce and consume messages in the `countries` topic. For the Node.js application in this example, the consumer group you must specify in your permissions is called `consumer-test`. To learn how to configure access permissions for a Kafka instance, see {base-url}{access-mgmt-url-kafka}[Managing account access in {product-long-kafka}^].
247246

248247
.Procedure
249248
. On the command line, navigate to the `reactive-example` directory of the repository that you cloned.

0 commit comments

Comments
 (0)