Kafka authorization

Ranger policies control which Kafka operations each user can perform and determine what is visible and manageable in Cloudera Surveyor.

Authorization model

A Ranger policy for Kafka specifies a resource, a set of permitted operations, and the principals the policy applies to. An administrator configures these policies in Ranger to define who can access which Kafka resources and what they can do with them.

Kafka enforces these policies for every access request. When a client application, a command-line tool, or Cloudera Surveyor attempts an operation such as reading messages, creating a topic, or resetting consumer group offsets, Kafka evaluates the request against the Ranger policies configured for the cluster. If a matching allow policy exists for the requesting principal, the request proceeds. If no matching policy exists, Ranger denies the request. Kafka ACLs are not supported and cannot be defined for a Kafka cluster deployed with Cloudera Streams Messaging.

Cloudera Surveyor access and Kafka authorization

Ranger is the sole authorization layer for Cloudera Surveyor. A user's Kafka policies in Ranger determine what Kafka resources they can view and manage in Cloudera Surveyor. There is no separate Cloudera Surveyor authorization configuration. Configuring a user's Kafka access in Ranger configures their Cloudera Surveyor access.

Ranger permissions affect Cloudera Surveyor in two distinct ways:

  • Visibility: Describe permission on a resource controls whether that resource appears in Cloudera Surveyor. Describe on Cluster is the mandatory entry point. Without it, the cluster and all of its topics, consumer groups, and other resources are hidden, regardless of what other permissions the user holds. No topic or consumer group permission implies Describe on Cluster. For resources within a visible cluster, Describe on each individual resource controls whether that resource appears. Resources the user cannot access are filtered from view.
  • Management actions: Action permissions such as Delete, Create, and Alter Configs control whether the corresponding operations are authorized.

Programmatic clients and principals

When connecting your own applications or command line tools to Kafka, you use OAuth client credentials. You request these credentials through the Anywhere Cloud Console credential provisioning API. Kafka authenticates the connection using those credentials and authorizes the request based on policies defined in Ranger.

Ranger always evaluates a Anywhere Cloud Console username as the Kafka principal. For programmatic access, that username is the Anywhere Cloud Console user who requested the credentials from the provisioning endpoint. The credentials are permanently bound to that user. They do not create a separate client identity or application principal in Ranger. The Ranger policies assigned to that username define what the connected client may do, whether the client is a long-running service or a command-line tool run by an administrator.

Kafka does not maintain a separate user store. To grant a programmatic client access to specific Kafka resources, you add the bound username to the relevant Ranger policies. To limit an application to a controlled set of permissions, use a dedicated Anywhere Cloud Console account for that workload:

  • Create or identify a dedicated Anywhere Cloud Console account for the application.
  • Configure the appropriate Ranger policies for that account's username.
  • Sign in as that account and request client credentials from the provisioning API.

See Connecting Kafka clients for the credential generation procedure.

Kafka resources and Ranger permissions

Ranger controls Kafka access through five resource types, each with a distinct set of permissions that control which operations a principal can perform.

The Kafka resources are as follows:

  • Topic
  • Consumer Group
  • Cluster
  • Transactional ID
  • Delegation Token

For each resource, a set of permissions controls which operations principals can perform. A user can access Kafka resources in two ways: directly, or through Cloudera Surveyor. Direct access includes applications that connect to Kafka, such as producers and consumers, as well as command-line tools that you run yourself. The tables in the following sections describe both. The Kafka access column describes what a permission allows for direct access, and the Cloudera Surveyor access column describes what it allows in the Cloudera Surveyor UI.

Topic permissions

The Topic resource represents Kafka topics, the named streams of messages that producers write to and consumers read from.

Table 1. Ranger permissions for the Kafka Topic resource
Permission Kafka access Cloudera Surveyor access
Describe Read topic metadata (partition count, replication, offsets) Topic appears in the topic list; topic details page is accessible
Describe Configs Read topic configuration values Topic configuration values are visible on the topic details page
Consume Read messages from the topic; commit offsets Can reset consumer group offsets for this topic. Partitions of this topic appear on the Partitions and Transactions tabs of Producer Details pages.
Publish Write messages to the topic No effect
Create Create new topics Can create topics
Delete Delete topics Can delete topics
Alter Add partitions; reassign partition replicas Can increase the topic partition count
Alter Configs Modify topic configuration values Can edit topic configuration properties
Configure Read topic configuration values. This is a legacy permission that maps to the same Kafka ACL operation as Describe Configs. Use Describe Configs instead. Topic configuration values are visible on the topic details page

Consumer group permissions

The Consumer Group resource represents Kafka consumer groups. A consumer group is a set of consumers that share the work of reading from one or more topics and track their progress through committed offsets.

Table 2. Ranger permissions for the Kafka Consumer Group resource
Permission Kafka access Cloudera Surveyor access
Describe Read consumer group membership, state, and offset data Consumer group appears in the consumer groups list; group details page is accessible
Consume Join the group and commit offsets; reset committed offsets Can edit committed offsets
Delete Delete the consumer group Can delete the consumer group

Cluster permissions

The Cluster resource represents the Kafka cluster as a whole. It controls cluster-wide operations and broker configuration.

Table 3. Ranger permissions for the Kafka Cluster resource
Permission Kafka access Cloudera Surveyor access
Describe Read cluster metadata (controller, broker IDs) Cluster appears in the Cloudera Surveyor cluster list. Brokers, producers, and transactions in the cluster are visible.
Describe Configs Read broker configuration values Broker configuration values are visible in Cloudera Surveyor
Create Create topics without a topic-level Create policy Can create topics (alternative to Topic: Create)
Alter Alter cluster-level settings such as partition reassignment and leader election No effect
Alter Configs Modify broker configuration values Can edit broker configuration properties
Configure Read broker configuration values. This is a legacy permission that maps to the same Kafka ACL operation as Describe Configs. Use Describe Configs instead. Broker configuration values are visible in Cloudera Surveyor
Idempotent Write Produce messages idempotently to any topic; required when enable.idempotence=true is configured on the producer No effect
Cluster Action Perform internal broker-to-broker and controller operations; typically required by Kafka service accounts No effect
Kafka Admin All Kafka access granted by the other Cluster permissions All Cloudera Surveyor access granted by the other Cluster permissions

Transactional ID permissions

The Transactional ID resource represents the transactional IDs that producers use to write to Kafka with exactly-once semantics.

Table 4. Ranger permissions for the Kafka Transactional ID resource
Permission Kafka access Cloudera Surveyor access
Describe Read transactional state and metadata No effect
Publish Write transactional messages using this transactional ID Can abort transactions that use this transactional ID

Delegation token permissions

Delegation tokens are a Kafka authentication mechanism that allows a Kerberos-authenticated principal to generate short-lived tokens for use by other processes. These permissions have no effect in Cloudera Surveyor.

Table 5. Ranger permissions for the Kafka Delegation Token resource
Permission Kafka access Cloudera Surveyor access
Describe Read delegation token metadata No effect

Implied grants

Ranger defines implied grants for Kafka and expands them automatically. Granting certain permissions automatically implies others, so you do not need to add them separately. Implied grants apply to any resource that supports both the granting permission and the implied permission. For example, Publish implies Describe on any resource that has both Publish and Describe available. If a resource does not support the granting permission, the implied grant does not apply. The following table lists all implied grants:

Table 6. Implied grants for Ranger Kafka permissions
Permission Implies
Publish Describe
Consume Describe
Configure Describe
Delete Describe
Alter Configs Describe Configs
Kafka Admin on Cluster All other permissions on the Cluster resource