- config the server.properties to run with SASL OAUTHBEARER test mode
listeners=SASL_PLAINTEXT://localhost:9093
advertised.listeners=SASL_PLAINTEXT://localhost:9093
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=OAUTHBEARER
sasl.enabled.mechanisms=OAUTHBEARER
# Specify the JAAS login context name for SASL/OAUTHBEARER
listener.name.sasl_plaintext.oauthbearer.sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required unsecuredLoginStringClaim_sub="alice";
- start the zookeeper and kafka server
zookeeper-server-start.bat .configzookeeper.properties
kafka-server-start.bat .configserver.properties
- next create a file client.properties in the config folder for kafka-topic script to use
security.protocol=SASL_PLAINTEXT
sasl.mechanism=OAUTHBEARER
sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required unsecuredLoginStringClaim_sub="alice";
- ccreate topic 'gaming-events' by kafka-topic script
kafka-topics.bat --create --topic gaming-events --bootstrap-server localhost:9093 --command-config .configclient.properties
kafka-topics.bat --list --bootstrap-server localhost:9093 --command-config .configclient.properties
- next modify consumer.properties/producer.properties the same as client.properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=OAUTHBEARER
sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required unsecuredLoginStringClaim_sub="alice";
- finally start the consumer and producer communicating through the topic 'gaming-events'
kafka-console-consumer.bat --topic gaming-events --from-beginning --bootstrap-server localhost:9093 --consumer.config .configconsumer.properties
kafka-console-producer.bat --topic gaming-events --bootstrap-server localhost:9093 --producer.config .configproducer.properties
This is just a test setting of OAUTHBEARER for kafka.