Kafka Users, Topic Names and ACL Roles

How the Kafka ACL Component names users, topics and consumer groups, what each ACL role allows, and how to grant one application access to another's topics.

This page explains what a Kafka ACL Component creates, how the names it
generates are built, and what each ACL role allows, so you can read an
authorisation error or ask for exactly the access an application needs.

What one Kafka ACL Component creates

Each Kafka ACL Component describes one Kafka user in one tenant on one
Kafka cluster. From it the platform creates:

  • the Kafka user, authenticated with SCRAM-SHA-512;
  • a secret holding that user's credentials, in the namespace the Component is
    deployed to, ready to inject into your application — see
    Kafka Access, ACLs and Topics;
  • the ACLs: the user's default rights on its own topics, plus any extra grants
    you list.

The Component can be deployed on its own, or bundled into an application's
deployment so the application and its Kafka user are created together.

The values

belongsTo: shared
cluster: kafka-bootstrap.kafka.svc.cluster.local
tenant: vote
user: api
consumerGroups: []
idempotent: false
acls: []
rawAcls: []
global: {}
metadata: {}
ValueMeaning
belongsToThe Kafka instance name, usually shared.
clusterThe bootstrap service. Leave it as it is.
tenantYour tenant, usually the namespace your applications run in. It is added to every user, topic and consumer group name.
userThe short name of this application's user, such as api.
consumerGroupsExtra consumer groups this user may join, beyond its own.
idempotenttrue grants the cluster-level rights (IdempotentWrite, TransactionalDescribe) that transactional producers need.
aclsGrants to other users on this tenant's topics.
rawAclsGrants on topics whose names do not follow the naming convention.
globalHolds acls instead of the top level when the Component is bundled into an application deployment.
metadataSet by the platform (stage, Environment, cloud). Do not edit.

The names it generates

Every name starts with the stage and tenant. With stage dev, tenant vote and
user api:

WhatPatternExample
Kafka user<stage>-<tenant>-<user>-userdev-vote-api-user
Credentials secretsview-kafka-<stage>-<tenant>-<user>-usersview-kafka-dev-vote-api-user
The user's own topics<stage>.<tenant>.<user>.*dev.vote.api.events
The user's own consumer groups<stage>.<tenant>.<user>.*dev.vote.api.worker

A user has full rights on topics and consumer groups under its own prefix
without any extra configuration. Name your topics to match — dev.vote.api.events
rather than events — and the owning application needs no ACL entries at all.

Granting another application access

List the grant under acls in the Component of the user that owns the
topics. Write the topic without the <stage>.<tenant>. part and the user as
its short name; both are completed for you:

tenant: vote
user: api
acls:
  - topic: api.events        # becomes dev.vote.api.events
    role: reader
    user: ui                 # becomes dev-vote-ui-user
  - topic: api.commands.     # every topic starting with dev.vote.api.commands.
    role: multiwriter
    user: worker

Because both names are completed with the same tenant, acls grants access to
users in the same tenant. For a topic outside the naming convention, such as
a connector's internal topic, use rawAcls: its topic name is used exactly as
written.

ACL roles

Roles without multi apply to one exact topic name. Roles with multi apply to
every topic that starts with the given prefix, so end the prefix with a dot.

RoleRightsApplies to
readerReadOne topic
multireaderReadEvery topic with the prefix
writerWrite, which includes readOne topic
multiwriterWrite, which includes readEvery topic with the prefix
adminAll operationsOne topic
multiadminAll operationsEvery topic with the prefix
readclusterRead cluster metadataThe cluster (the topic value is ignored)

Consumer groups

A user can always join consumer groups under its own <stage>.<tenant>.<user>.
prefix. To let it join another group, add the group's name without the stage
and tenant:

user: api
consumerGroups:
  - name: reporting.        # lets dev-vote-api-user join dev.vote.reporting.*

Reading an authorisation error

ErrorWhat is missing
TOPIC_AUTHORIZATION_FAILED / TopicAuthorizationExceptionAn ACL for this user on that topic, with a role that allows the operation.
GROUP_AUTHORIZATION_FAILED / GroupAuthorizationExceptionThe consumer group under the user's prefix or in consumerGroups.
CLUSTER_AUTHORIZATION_FAILED on a produceridempotent: true for a transactional producer.
UNKNOWN_TOPIC_OR_PARTITIONThe topic does not exist. Topics are never created automatically — declare it first, see Kafka Access, ACLs and Topics.
Authentication fails right after a changeThe new user or password has not reached the cluster yet. Wait a minute or two and restart the client.

Related articles


Did this page help you?