Client authentication configuration in Kafka - Commands & Configuration
listeners=SASL_PLAINTEXT://:9092 advertised.listeners=SASL_PLAINTEXT://localhost:9092 security.inter.broker.protocol=SASL_PLAINTEXT sasl.enabled.mechanisms=PLAIN sasl.mechanism.inter.broker.protocol=PLAIN listener.name.sasl_plaintext.plain.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="admin-secret";
listeners: Defines the protocol and port Kafka listens on with SASL_PLAINTEXT for authentication without encryption.
advertised.listeners: The address clients use to connect to Kafka.
security.inter.broker.protocol: Protocol used between Kafka brokers, here also SASL_PLAINTEXT.
sasl.enabled.mechanisms: Enables the PLAIN mechanism for username/password authentication.
sasl.mechanism.inter.broker.protocol: Mechanism used between brokers.
listener.name.sasl_plaintext.plain.sasl.jaas.config: Configures the JAAS login module with username and password for authentication.
kafka-server-start.sh server.properties
kafka-console-producer.sh --broker-list localhost:9092 --topic test-topic --producer-property sasl.mechanism=PLAIN --producer-property security.protocol=SASL_PLAINTEXT --producer-property sasl.jaas.config='org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="admin-secret";'
--producer-property sasl.mechanism=PLAIN - Specifies the SASL mechanism for authentication.--producer-property security.protocol=SASL_PLAINTEXT - Defines the security protocol to use SASL without encryption.kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test-topic --from-beginning --consumer-property sasl.mechanism=PLAIN --consumer-property security.protocol=SASL_PLAINTEXT --consumer-property sasl.jaas.config='org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="admin-secret";'
--consumer-property sasl.mechanism=PLAIN - Specifies the SASL mechanism for authentication.--consumer-property security.protocol=SASL_PLAINTEXT - Defines the security protocol to use SASL without encryption.If you remember nothing else from this pattern, remember: client authentication in Kafka uses SASL mechanisms configured on both broker and client sides to verify identities before allowing access.