{"id":136173,"date":"2025-08-15T14:02:30","date_gmt":"2025-08-15T11:02:30","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=136173"},"modified":"2025-08-15T14:02:32","modified_gmt":"2025-08-15T11:02:32","slug":"kafka-security-with-sasl-plain-authentication","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html","title":{"rendered":"Kafka Security with SASL\/PLAIN Authentication"},"content":{"rendered":"<p>Kafka is a distributed streaming platform widely used for building real-time data pipelines and streaming applications. Security is a critical aspect when deploying Kafka in production environments. One of the simplest ways to secure Kafka is by using SASL\/PLAIN authentication, which provides username-password based authentication between clients and Kafka brokers. Let us delve into understanding Kafka authentication using SASL\/PLAIN.<\/p>\n<h2><a name=\"section-1\"><\/a>1. What is Kafka? What is SASL\/PLAIN Authentication?<\/h2>\n<p>Kafka is an <a href=\"https:\/\/kafka.apache.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">open-source distributed event streaming platform<\/a> capable of handling trillions of events a day. It allows producers to send messages to topics, and consumers to read these messages in real time or batch mode. Kafka provides high throughput, fault tolerance, and scalability. <\/p>\n<p>SASL (<a href=\"https:\/\/tools.ietf.org\/html\/rfc4422\" target=\"_blank\" rel=\"noopener noreferrer\">Simple Authentication and Security Layer<\/a>) is a framework that adds authentication support to connection-based protocols. SASL\/PLAIN is one mechanism under SASL that uses a simple username and password for client authentication. Though not encrypted by itself, SASL\/PLAIN is often used in conjunction with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Transport_Layer_Security\" target=\"_blank\" rel=\"noopener noreferrer\">TLS<\/a> to protect credentials over the network. Using SASL\/PLAIN with Kafka, the client authenticates with the broker using a configured username and password, enabling controlled access to Kafka topics and operations.<\/p>\n<h2><a name=\"section-2\"><\/a>2. Code Example<\/h2>\n<h3>2.1 Setting Up Kafka on Docker with SASL\/PLAIN<\/h3>\n<p>Below is a detailed guide and configuration for running Kafka and Zookeeper using Docker Compose with SASL\/PLAIN authentication enabled. This setup enables Kafka brokers to require username-password authentication, improving the security of Kafka communications.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\nversion: '3'\nservices:\n  zookeeper:\n    image: wurstmeister\/zookeeper:3.4.6\n    ports:\n      - \"2181:2181\"\n\n  kafka:\n    image: wurstmeister\/kafka:2.12-2.2.1\n    ports:\n      - \"9092:9092\"\n    environment:\n      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181\n      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT:\/\/localhost:9092,SASL_PLAINTEXT:\/\/localhost:9093\n      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,SASL_PLAINTEXT:SASL_PLAINTEXT\n      KAFKA_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT\n      KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: PLAIN\n      KAFKA_AUTHORIZER_CLASS_NAME: kafka.security.auth.SimpleAclAuthorizer\n      KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: 'true'\n      KAFKA_SUPER_USERS: User:admin\n      KAFKA_OPTS: \"-Djava.security.auth.login.config=\/opt\/kafka\/config\/kafka_server_jaas.conf\"\n    volumes:\n      - .\/kafka_server_jaas.conf:\/opt\/kafka\/config\/kafka_server_jaas.conf\n    depends_on:\n      - zookeeper\n<\/pre>\n<p>This Docker Compose configuration defines two services: <code>zookeeper<\/code> and <code>kafka<\/code>. The <code>zookeeper<\/code> service uses the <code>wurstmeister\/zookeeper:3.4.6<\/code> image and exposes port 2181 to allow Kafka to coordinate broker metadata and cluster state. The <code>kafka<\/code> service uses the <code>wurstmeister\/kafka:2.12-2.2.1<\/code> image, exposes port 9092 for client connections, and is configured to connect to the Zookeeper service at <code>zookeeper:2181<\/code>. Kafka is set up with two listeners: a PLAINTEXT listener on port 9092 and a SASL_PLAINTEXT listener on port 9093, with the inter-broker communication secured using SASL\/PLAIN mechanism. It uses the <code>SimpleAclAuthorizer<\/code> to control access with an open policy allowing everyone if no ACL is found, and designates the user <code>admin<\/code> as a superuser. The configuration file for Java Authentication and Authorization Service (JAAS) is mounted into the container at runtime via a volume mount from the local file <code>kafka_server_jaas.conf<\/code>. The Kafka service depends on Zookeeper to ensure proper startup order, allowing Kafka to rely on Zookeeper for distributed coordination. This setup facilitates a secure Kafka broker with SASL\/PLAIN authentication running alongside Zookeeper within Docker containers. <\/p>\n<h4>2.1.1 Server Configuration<\/h4>\n<p>Create a file named <code>kafka_server_jaas.conf<\/code> with the following content:<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\nKafkaServer {\n  org.apache.kafka.common.security.plain.PlainLoginModule required\n  username=\"admin\"\n  password=\"admin-secret\"\n  user_admin=\"admin-secret\"\n  user_alice=\"alice-secret\";\n};\n<\/pre>\n<p>This <code>kafka_server_jaas.conf<\/code> file configures the Kafka broker&#8217;s JAAS (Java Authentication and Authorization Service) settings to enable SASL\/PLAIN authentication; it defines a <code>KafkaServer<\/code> section using the <code>PlainLoginModule<\/code> where the broker authenticates clients by matching usernames and passwords, specifying <code>admin<\/code> as the principal username with its password <code>admin-secret<\/code>, and also listing additional valid users such as <code>admin<\/code> and <code>alice<\/code> with their respective passwords <code>admin-secret<\/code> and <code>alice-secret<\/code>, allowing these users to connect securely to Kafka brokers using SASL\/PLAIN mechanism for authentication. <div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h4>2.1.2 How to Run the Kafka and Zookeeper Docker Setup?<\/h4>\n<p>Go to the Docker folder in the terminal and run this command to start the containers in the background:<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\ndocker-compose up -d\n<\/pre>\n<p>This command will launch the Zookeeper service on port 2181 and the Kafka broker on ports 9092 (PLAINTEXT) and 9093 (SASL_PLAINTEXT), applying the SASL\/PLAIN authentication and authorization configurations as defined in the Docker Compose file and JAAS configuration file, thereby preparing a secured Kafka environment ready for client connections.<\/p>\n<h4>2.1.3 How to Create a Kafka Topic?<\/h4>\n<p>Kafka topics are like channels where producers send messages and consumers receive them. Before you can send or get messages, you must create the topic on the Kafka broker. To do this, log into the Kafka container and run the following command inside it:<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">\nkafka-topics.sh --create \\\n  --topic test-topic \\\n  --bootstrap-server localhost:9092 \\\n  --partitions 3 \\\n  --replication-factor 1\n<\/pre>\n<h3>2.2 Implement Kafka with SASL\/PLAIN Authentication in Spring Boot<\/h3>\n<p>Below is a detailed Spring Boot example demonstrating a Kafka producer and consumer configured to use SASL\/PLAIN authentication.<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">\n@Configuration\npublic class KafkaConfig {\n\n    @Value(\"${spring.kafka.bootstrap-servers}\")\n    private String bootstrapServers;\n\n    @Value(\"${spring.kafka.properties.sasl.jaas.config}\")\n    private String jaasConfig;\n\n    \/\/ Producer configuration\n    @Bean\n    public Map&lt;String, Object&gt; producerConfigs() {\n        Map&lt;String, Object&gt; props = new HashMap&lt;&gt;();\n        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);\n        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);\n        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);\n\n        \/\/ Enable SASL\/PLAIN authentication\n        props.put(\"security.protocol\", \"SASL_PLAINTEXT\");\n        props.put(\"sasl.mechanism\", \"PLAIN\");\n        props.put(\"sasl.jaas.config\", jaasConfig);\n\n        return props;\n    }\n\n    @Bean\n    public ProducerFactory&lt;String, String&gt; producerFactory() {\n        return new DefaultKafkaProducerFactory&lt;&gt;(producerConfigs());\n    }\n\n    @Bean\n    public KafkaTemplate&lt;String, String&gt; kafkaTemplate() {\n        return new KafkaTemplate&lt;&gt;(producerFactory());\n    }\n\n    \/\/ Consumer configuration\n    @Bean\n    public Map&lt;String, Object&gt; consumerConfigs() {\n        Map&lt;String, Object&gt; props = new HashMap&lt;&gt;();\n        props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);\n        props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);\n        props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);\n        props.put(ConsumerConfig.GROUP_ID_CONFIG, \"group_id\");\n        props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, \"earliest\");\n\n        \/\/ Enable SASL\/PLAIN authentication\n        props.put(\"security.protocol\", \"SASL_PLAINTEXT\");\n        props.put(\"sasl.mechanism\", \"PLAIN\");\n        props.put(\"sasl.jaas.config\", jaasConfig);\n\n        return props;\n    }\n\n    @Bean\n    public ConsumerFactory&lt;String, String&gt; consumerFactory() {\n        return new DefaultKafkaConsumerFactory&lt;&gt;(consumerConfigs());\n    }\n\n    @Bean\n    public ConcurrentKafkaListenerContainerFactory&lt;String, String&gt; kafkaListenerContainerFactory() {\n        ConcurrentKafkaListenerContainerFactory&lt;String, String&gt; factory = \n            new ConcurrentKafkaListenerContainerFactory&lt;&gt;();\n        factory.setConsumerFactory(consumerFactory());\n        return factory;\n    }\n}\n<\/pre>\n<p>This Java Spring configuration class <code>KafkaConfig<\/code> sets up both Kafka producer and consumer with SASL\/PLAIN authentication; it reads the Kafka bootstrap server address and JAAS configuration string from properties, defines producer properties including bootstrap servers, serializers, and security settings for SASL\/PLAIN via <code>security.protocol<\/code>, <code>sasl.mechanism<\/code>, and <code>sasl.jaas.config<\/code>, then creates a <code>ProducerFactory<\/code> and a <code>KafkaTemplate<\/code> bean for producing messages. Similarly, it defines consumer properties including deserializers, group ID, auto offset reset, and identical SASL\/PLAIN security configurations, followed by a <code>ConsumerFactory<\/code> and a concurrent listener container factory bean to enable message consumption with secure authentication. This setup ensures that both Kafka producers and consumers connect securely to Kafka brokers using SASL\/PLAIN over the specified bootstrap servers in a Spring Boot application.<\/p>\n<h3>2.3 Setting up the configuration<\/h3>\n<p>Define the JAAS configuration in <code>application.properties<\/code>:<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\nspring.kafka.bootstrap-servers=localhost:9093\n\nspring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username=\"alice\" password=\"alice-secret\";\n<\/pre>\n<p>This configuration snippet sets Kafka client properties in the <code>application.properties<\/code> file for a Spring Boot application, specifying the Kafka broker address at <code>localhost:9093<\/code> under <code>spring.kafka.bootstrap-servers<\/code>, and defining the JAAS login module configuration string for SASL\/PLAIN authentication under <code>spring.kafka.properties.sasl.jaas.config<\/code>; it uses the <code>PlainLoginModule<\/code> with the required username <code>alice<\/code> and password <code>alice-secret<\/code>, ensuring the Kafka client authenticates securely with the broker using the SASL\/PLAIN mechanism, with special attention to properly escaping the double quotes in the properties file to avoid syntax errors during loading.<\/p>\n<h3>2.4 Producer Service<\/h3>\n<p>Create a simple Kafka producer service. This Java Spring service class <code>KafkaProducer<\/code> uses dependency injection to receive a <code>KafkaTemplate<\/code> configured for sending string key-value messages, and provides a method <code>sendMessage<\/code> that takes a Kafka topic name and a message string, then sends the message asynchronously to the specified topic using the <code>kafkaTemplate.send()<\/code> method, followed by printing a confirmation to the console indicating the message content and target topic, enabling simple and reusable Kafka message production within a Spring application.<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">\n@Service\npublic class KafkaProducer {\n    private final KafkaTemplate&lt;String, String&gt; kafkaTemplate;\n\n    public KafkaProducer(KafkaTemplate&lt;String, String&gt; kafkaTemplate) {\n        this.kafkaTemplate = kafkaTemplate;\n    }\n\n    public void sendMessage(String topic, String message) {\n        kafkaTemplate.send(topic, message);\n        System.out.println(\"Sent message: \" + message + \" to topic: \" + topic);\n    }\n}\n<\/pre>\n<h3>2.5 Consumer Service<\/h3>\n<p>Create a Kafka consumer to listen on the topic. This Java Spring component class <code>KafkaConsumer<\/code> listens to messages from the Kafka topic <code>test-topic<\/code> within the consumer group <code>group_id<\/code> using the <code>@KafkaListener<\/code> annotation; the <code>listen<\/code> method is triggered automatically whenever a new message arrives on the specified topic, receiving the message as a string parameter and printing it to the console, thus providing a simple way to consume and process Kafka messages asynchronously in a Spring application.<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">\n@Component\npublic class KafkaConsumer {\n\n    @KafkaListener(topics = \"test-topic\", groupId = \"group_id\")\n    public void listen(String message) {\n        System.out.println(\"Received message: \" + message);\n    }\n}\n<\/pre>\n<h3>2.6 Main Class<\/h3>\n<p>In the main application or a command line runner, send a test message.<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">\n@SpringBootApplication\npublic class KafkaSaslPlainApplication implements CommandLineRunner {\n\n    private final KafkaProducer kafkaProducer;\n\n    public KafkaSaslPlainApplication(KafkaProducer kafkaProducer) {\n        this.kafkaProducer = kafkaProducer;\n    }\n\n    public static void main(String[] args) {\n        SpringApplication.run(KafkaSaslPlainApplication.class, args);\n    }\n\n    @Override\n    public void run(String... args) throws Exception {\n        kafkaProducer.sendMessage(\"test-topic\", \"Hello Kafka with SASL\/PLAIN!\");\n    }\n}\n<\/pre>\n<h3>2.7 Code Run and Output<\/h3>\n<p>When you run the application, this output appears on the console.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\n\/\/ Producer\nHello Kafka with SASL\/PLAIN! \n\n\/\/ Consumer \nReceived message: Hello Kafka with SASL\/PLAIN!\n<\/pre>\n<p>The output shown reflects the interaction between the Kafka producer and consumer in the Spring Boot application configured with SASL\/PLAIN authentication. When the application starts, the <code>KafkaSaslPlainApplication<\/code> class executes its <code>run<\/code> method (because it implements <code>CommandLineRunner<\/code>), which calls the <code>sendMessage<\/code> method of the <code>KafkaProducer<\/code> service. This method sends the message <code>\"Hello Kafka with SASL\/PLAIN!\"<\/code> to the Kafka topic named <code>test-topic<\/code> and immediately prints a confirmation: <code>Sent message: Hello Kafka with SASL\/PLAIN! to topic: test-topic<\/code>. This indicates the producer successfully dispatched the message to the Kafka broker.<\/p>\n<p>Meanwhile, the <code>KafkaConsumer<\/code> component is actively listening to the same topic <code>test-topic<\/code> within the consumer group <code>group_id<\/code>. Once the message arrives on the broker, Kafka delivers it to the consumer, triggering the annotated method <code>listen(String message)<\/code>. This method receives the message payload and prints it out to the console: <code>Received message: Hello Kafka with SASL\/PLAIN!<\/code>. This confirms the message was successfully consumed by the client application.<\/p>\n<p>Behind the scenes, this entire process is secured by SASL\/PLAIN authentication, where both producer and consumer authenticate with the Kafka broker using configured usernames and passwords, as specified in the JAAS configuration. Although the output itself only shows message send and receive logs, the security configuration ensures that only authenticated clients can connect, publish, and consume messages, preventing unauthorized access.<\/p>\n<p>Thus, the output provides visible evidence of the Kafka messaging flow working end-to-end: the producer sends a message, the Kafka broker routes it to the topic, and the consumer receives and processes it, all while enforcing security via SASL\/PLAIN authentication.<\/p>\n<h2><a name=\"section-3\"><\/a>3. Conclusion<\/h2>\n<p>Securing Kafka with SASL\/PLAIN authentication provides a straightforward way to enforce username-password based client authentication. While SASL\/PLAIN itself does not encrypt credentials, combining it with TLS ensures secure transmission. This article demonstrated how to set up Kafka with SASL\/PLAIN on Docker and how to configure a Spring Boot Kafka client to authenticate securely. This approach helps protect Kafka clusters from unauthorized access and is suitable for many enterprise environments. Implementing SASL\/PLAIN in your Kafka setup improves security with minimal complexity, making it a good first step before moving to more advanced authentication mechanisms like SCRAM or OAuth.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kafka is a distributed streaming platform widely used for building real-time data pipelines and streaming applications. Security is a critical aspect when deploying Kafka in production environments. One of the simplest ways to secure Kafka is by using SASL\/PLAIN authentication, which provides username-password based authentication between clients and Kafka brokers. Let us delve into understanding &hellip;<\/p>\n","protected":false},"author":26931,"featured_media":118161,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[2153,1349,2574,125],"class_list":["post-136173","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-docker-compose","tag-kafka","tag-kafka-cli","tag-spring-security"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Kafka Security with SASL\/PLAIN Authentication - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Kafka authentication sasl plain: Learn how to secure Kafka using SASL\/PLAIN authentication with username and password setup.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kafka Security with SASL\/PLAIN Authentication - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Kafka authentication sasl plain: Learn how to secure Kafka using SASL\/PLAIN authentication with username and password setup.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-15T11:02:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-15T11:02:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/08\/apache-kafka-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin Batra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin Batra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html\"},\"author\":{\"name\":\"Yatin Batra\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\"},\"headline\":\"Kafka Security with SASL\\\/PLAIN Authentication\",\"datePublished\":\"2025-08-15T11:02:30+00:00\",\"dateModified\":\"2025-08-15T11:02:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html\"},\"wordCount\":1346,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/apache-kafka-logo.jpg\",\"keywords\":[\"Docker Compose\",\"Kafka\",\"Kafka CLI\",\"Spring Security\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html\",\"name\":\"Kafka Security with SASL\\\/PLAIN Authentication - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/apache-kafka-logo.jpg\",\"datePublished\":\"2025-08-15T11:02:30+00:00\",\"dateModified\":\"2025-08-15T11:02:32+00:00\",\"description\":\"Kafka authentication sasl plain: Learn how to secure Kafka using SASL\\\/PLAIN authentication with username and password setup.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/apache-kafka-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/apache-kafka-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/kafka-security-with-sasl-plain-authentication.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Kafka Security with SASL\\\/PLAIN Authentication\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\",\"name\":\"Yatin Batra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"caption\":\"Yatin Batra\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\\\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\\\/\\\/www.javacodegeeks.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yatin-batra\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Kafka Security with SASL\/PLAIN Authentication - Java Code Geeks","description":"Kafka authentication sasl plain: Learn how to secure Kafka using SASL\/PLAIN authentication with username and password setup.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html","og_locale":"en_US","og_type":"article","og_title":"Kafka Security with SASL\/PLAIN Authentication - Java Code Geeks","og_description":"Kafka authentication sasl plain: Learn how to secure Kafka using SASL\/PLAIN authentication with username and password setup.","og_url":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2025-08-15T11:02:30+00:00","article_modified_time":"2025-08-15T11:02:32+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/08\/apache-kafka-logo.jpg","type":"image\/jpeg"}],"author":"Yatin Batra","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin Batra","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html"},"author":{"name":"Yatin Batra","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d"},"headline":"Kafka Security with SASL\/PLAIN Authentication","datePublished":"2025-08-15T11:02:30+00:00","dateModified":"2025-08-15T11:02:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html"},"wordCount":1346,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/08\/apache-kafka-logo.jpg","keywords":["Docker Compose","Kafka","Kafka CLI","Spring Security"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html","url":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html","name":"Kafka Security with SASL\/PLAIN Authentication - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/08\/apache-kafka-logo.jpg","datePublished":"2025-08-15T11:02:30+00:00","dateModified":"2025-08-15T11:02:32+00:00","description":"Kafka authentication sasl plain: Learn how to secure Kafka using SASL\/PLAIN authentication with username and password setup.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/08\/apache-kafka-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/08\/apache-kafka-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/kafka-security-with-sasl-plain-authentication.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Kafka Security with SASL\/PLAIN Authentication"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d","name":"Yatin Batra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","caption":"Yatin Batra"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/yatin-batra"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/136173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/26931"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=136173"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/136173\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/118161"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=136173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=136173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=136173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}