Configuring ACL for kafka topic
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Apache Kafka, a popular distributed event streaming platform used for building real-time data pipelines and streaming applications, provides robust security measures. One such feature is Access Control Lists (ACLs) which are vital for ensuring that only authorized users and applications can access certain Kafka resources. This article delves into the configuration of ACLs for Kafka topics, offering both technical explanations and practical examples.
Understanding Kafka ACLs
ACLs in Kafka determine the actions (read, write, etc.) that principals (users or applications) can perform on Kafka resources like topics, consumer groups, or the cluster itself. Kafka uses these ACLs in conjunction with authentication mechanisms such as SASL (Simple Authentication and Security Layer) or SSL/TLS to secure its environment.
Configuring ACLs in Kafka
Kafka's ACLs are managed through the Kafka Authorizer, and the most commonly used authorizer is the SimpleAclAuthorizer. Here is a step-by-step guide on how to configure ACLs for a Kafka topic:
Step 1: Enable the Authorizer
First, ensure that the Kafka broker configuration enables the SimpleAclAuthorizer. Modify the server.properties file of your Kafka broker to include:
Here, super.users are those who have all permissions across all Kafka resources.
Step 2: Set Up ZooKeeper ACLs
Kafka uses ZooKeeper for managing cluster metadata and by default, it's not secured. Kafka's ACLs can be stored in ZooKeeper, and securing ZooKeeper is an important step.
Step 3: Add ACLs for a Topic
To add an ACL that allows a user to perform specific actions on a topic, you can use the Kafka ACL command-line tool. Below is the command to grant user john the permission to read from the topic sales-data:
Examples of Common ACL Configurations
- Allowing Write Access: To allow a user to write to a topic, modify the
--operationto Write in the above command. - Allowing All Access to a Topic: You can allow a user both read and write access by adding two separate ACL entries or by specifying
--operation All.
Step 4: Validate ACLs
After configuring ACLs, you can verify them by listing the ACLs for a topic using:
Best Practices and Considerations
- Principle of Least Privilege: Always grant the least amount of access needed for users and applications.
- Regularly Review and Audit ACLs: Ensure that outdated ACLs are removed and audit logs are periodically reviewed for unexpected access patterns.
- Secure ZooKeeper: As ACLs and other sensitive metadata are stored in ZooKeeper, it's crucial to secure ZooKeeper using ACLs and encryption.
Summary Table
| Feature | Description |
| ACL Configuration | Managed via SimpleAclAuthorizer and Kafka CLI. |
| Primary Commands | kafka-acls.sh to add, remove, or list ACLs. |
| Security | Works alongside Kafka's authentication mechanisms. |
| ZooKeeper | Must be secured as it stores ACLs and other critical metadata. |
Conclusion
Configuring ACLs in Kafka is an essential task for securing Kafka topics and ensuring that sensitive data is only accessible by authorized entities. By following the outlined steps and adhering to best practices, organizations can significantly enhance their Kafka security posture.

