Managing Access Control
1. Understanding ACL Model
| Element | Description | Detail |
|---|---|---|
| Principal | Who (User:name) | Identity |
| Operation | What (Read/Write) | Action |
| Resource | On what (Topic/Group) | Target |
2. Enabling Authorization
| Config | Description | Detail |
|---|---|---|
| authorizer.class.name | StandardAuthorizer (KRaft) | Required |
| allow.everyone. if.no.acl.found |
Default-deny vs allow | false in prod |
| super.users | Bypass ACLs | Admins |
Example: Enable authorizer
authorizer.class.name=org.apache.kafka.metadata.authorizer.StandardAuthorizer
allow.everyone.if.no.acl.found=false
3. Creating ACLs
| Flag | Description | Detail |
|---|---|---|
| --allow-principal | Grant to user | User:name |
| --operation | Read/Write/etc. | Action |
| --topic/--group | Resource | Target |
Example: Grant produce
kafka-acls.sh --bootstrap-server localhost:9092 --add \
--allow-principal User:producer --operation Write --topic orders
4. Listing ACLs
| Flag | Description | Detail |
|---|---|---|
| --list | Show ACLs | All/filtered |
| --topic | Filter by resource | Scoped |
| --principal | Filter by user | Per-user |
5. Removing ACLs
| Flag | Description | Detail |
|---|---|---|
| --remove | Delete matching ACL | Revoke |
| Match | Same principal+op+resource | Exact |
| --force | Skip prompt | Scripted |
Example: Remove ACL
kafka-acls.sh --bootstrap-server localhost:9092 --remove \
--allow-principal User:producer --operation Write --topic orders --force
6. Setting Principal Format
| Source | Principal | Detail |
|---|---|---|
| SSL | From cert DN | CN=... |
| SASL | From username | User:name |
| Mapping | ssl.principal. mapping.rules |
Regex rewrite |
7. Configuring Super Users
| Config | Description | Detail |
|---|---|---|
| super.users | Full access principals | Bypass ACL |
| Format | User:x;User:y | Semicolon |
| Use | Brokers, admins | Minimal |
8. Understanding ACL Operations
| Operation | Resource | Use |
|---|---|---|
| Read | Topic, Group | Consume |
| Write | Topic | Produce |
| Create/Delete | Topic, Cluster | Admin |
Example: Consumer needs Read on group
kafka-acls.sh --bootstrap-server localhost:9092 --add \
--allow-principal User:c --operation Read --group order-svc
9. Setting Resource Patterns
| Type | Description | Detail |
|---|---|---|
| LITERAL | Exact name | Default |
| PREFIXED | Name prefix match | --resource-pattern-type |
| Use | Team namespaces | orders.* |
Example: Prefixed ACL
kafka-acls.sh --bootstrap-server localhost:9092 --add \
--allow-principal User:team-a --operation Write \
--topic orders. --resource-pattern-type PREFIXED
10. Using Wildcard ACLs
| Wildcard | Description | Detail |
|---|---|---|
| Topic * | All topics | Broad |
| Principal * | Everyone | Public |
| Caution | Least privilege | Avoid broad |
Example: All-topics read
kafka-acls.sh --bootstrap-server localhost:9092 --add \
--allow-principal User:monitor --operation Read --topic '*'
11. Configuring ACL Binding
| Aspect | Description | Detail |
|---|---|---|
| AclBinding | Pattern + entry | Admin API |
| createAcls | Programmatic add | Batch |
| describeAcls | Query bindings | Filter |