📖 Scenario: You are setting up a Kafka cluster where different users have specific permissions to access topics. To keep the data safe, you will create Access Control Lists (ACLs) that allow or deny users certain actions on Kafka topics.
🎯 Goal: Build a simple Kafka ACL configuration that grants a user permission to read from a topic and denies another user from writing to the same topic.
📋 What You'll Learn
Create a Kafka topic named orders
Create an ACL that allows user alice to read from the orders topic
Create an ACL that denies user bob from writing to the orders topic
Verify the ACLs by listing them
💡 Why This Matters
🌍 Real World
Kafka ACLs help secure data streams by controlling who can read or write to topics, protecting sensitive information.
💼 Career
Understanding Kafka ACLs is important for roles like DevOps engineers, Kafka administrators, and backend developers working with secure data pipelines.
Progress0 / 4 steps
1
Create the Kafka topic orders
Use the Kafka CLI command to create a topic named orders with 1 partition and a replication factor of 1.
Kafka
Hint
Use kafka-topics.sh --create with the right options to create the topic.
2
Create an ACL to allow user alice to read from orders
Use the Kafka CLI command to add an ACL that allows the user alice to perform the READ operation on the orders topic.
Kafka
Hint
Use kafka-acls.sh --add with --allow-principal User:alice and --operation READ.
3
Create an ACL to deny user bob from writing to orders
Use the Kafka CLI command to add an ACL that denies the user bob the WRITE operation on the orders topic.
Kafka
Hint
Use kafka-acls.sh --add --deny-principal User:bob with --operation WRITE.
4
List all ACLs for the orders topic
Use the Kafka CLI command to list all ACLs for the orders topic to verify the permissions.
Kafka
Hint
Use kafka-acls.sh --list --topic orders to see the ACLs.
Practice
(1/5)
1. What is the main purpose of ACL-based authorization in Kafka?
easy
A. To control who can access Kafka topics and perform operations
B. To speed up message processing in Kafka
C. To store messages in a compressed format
D. To monitor Kafka cluster health
Solution
Step 1: Understand ACL-based authorization
ACL-based authorization is used to manage permissions for users or clients in Kafka.
Step 2: Identify its main role
Its main role is to control access to Kafka topics and operations, ensuring security.
Final Answer:
To control who can access Kafka topics and perform operations -> Option A
Quick Check:
ACL controls access = B [OK]
Hint: ACL means controlling access rights in Kafka [OK]
Common Mistakes:
Confusing ACL with performance tuning
Thinking ACL compresses data
Assuming ACL monitors cluster health
2. Which of the following is the correct command to add an ACL for a user named alice to read from topic orders?
easy
A. kafka-acls --add --allow-principal User:alice --operation Read --topic orders
B. kafka-acls --remove --allow-principal User:alice --operation Read --topic orders
C. kafka-acls --add --deny-principal User:alice --operation Write --topic orders
D. kafka-acls --add --allow-principal User:bob --operation Read --topic orders
Solution
Step 1: Identify the command to add ACL
The command to add an ACL uses --add and specifies the principal and operation.
Step 2: Match user, operation, and topic
We want to add read permission for user alice on topic orders, so the command must include these exactly.
But Carol still cannot read from the sales topic. What is the most likely cause?
medium
A. The ACL was added but the Kafka broker was not restarted
B. Carol needs Write permission to read messages
C. Carol's client is not authenticating as User:carol
D. The ACL was added for the wrong user
Solution
Step 1: Check if ACL command syntax is correct
The command correctly adds Read permission for User:carol on topic sales.
Step 2: Consider authentication and identity
If Carol cannot read despite ACL, likely her client is not authenticating as User:carol, so ACL does not apply.
Final Answer:
Carol's client is not authenticating as User:carol -> Option C
Quick Check:
ACL needs matching user identity = A [OK]
Hint: ACLs depend on correct user authentication [OK]
Common Mistakes:
Thinking Write permission is needed to read
Assuming Kafka broker restart is required for ACL changes
Confusing user names in ACL commands
5. You want to allow a group of users to produce messages to topic logs but deny them from deleting the topic. Which ACL commands correctly achieve this?
hard
A. Add allow ACL for Produce operation only; deny is not needed because deny is default
B. Add allow ACL for Produce operation and add deny ACL for Delete operation for the user group
C. Add allow ACL for Produce and Delete operations for the user group
D. Add deny ACL for Produce and allow ACL for Delete operations for the user group
Solution
Step 1: Understand permission requirements
The users should be allowed to produce messages but denied from deleting the topic.
Step 2: Use allow and deny ACLs appropriately
We add an allow ACL for Produce operation and explicitly add a deny ACL for Delete operation to prevent deletion.
Final Answer:
Add allow ACL for Produce operation and add deny ACL for Delete operation for the user group -> Option B
Quick Check:
Allow produce + deny delete = A [OK]
Hint: Use allow for produce and deny for delete explicitly [OK]
Common Mistakes:
Assuming deny is default without adding deny ACL
Allowing delete by mistake
Mixing up allow and deny commands
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.