Updated on 2026-06-27 GMT+08:00

Adding a Ranger Access Permission Policy for Kafka

Scenarios

As a core distributed message queue component, Kafka handles the real-time ingestion, transmission, and distribution of service data. It serves as a foundational layer in critical service workflows, including log aggregation, data synchronization, and stream processing. Users with different roles, such as data development engineers writing service data to Kafka topics, data analysts reading topic data for business intelligence, and O&M personnel managing cluster topics and configurations, must be granted access to specific Kafka resources based on the principle of least privilege.

Ranger provides a comprehensive access control solution for Kafka permissions. Through the Ranger web UI, administrators can configure fine-grained authorization policies for Kafka users, enabling enterprises to enforce secure management and strict control over Kafka resources.

Notes and Constraints

  • Generally, the Kafka supports topic creation, deletion, and query using either the --zookeeper or --bootstrap-server connection mode. The latest community Kafka releases have completely removed support for the --zookeeper mode. Therefore, you are strongly advised to use the --bootstrap-server mode to create, delete, and query your topics.
  • Currently, Kafka enforces authentication exclusively for topic creation, deletion, and query executed via the --bootstrap-server mode, whereas operations executed via the legacy --zookeeper mode do not support access control.

Prerequisites

  • The Ranger service has been installed and is running properly in the cluster.
  • The users, user groups, or roles requiring permissions must already be created in the cluster. For newly created users, you can configure permission policies only after the users are automatically synchronized to Ranger.

Procedure

  1. Log in to the Ranger web UI as the Ranger administrator. For details, see Logging In to the Ranger Web UI.
  2. On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
  3. Click Add New Policy to add a Kafka permission control policy.
  4. Configure the following parameters based on the service demands.

    Table 1 Kafka permission parameters

    Parameter

    Description

    Policy Type

    Policy type. An access policy controls permissions based on specific resource paths.

    Policy Conditions

    IP address filtering policy, which can be customized. You can configure the specific host nodes to which the current policy applies. The system supports one or more individual IP addresses or IP address ranges, and these input strings accept the wildcard character (*).

    For example: 192.168.1.10,192.168.1.20 or 192.168.1.*.

    Policy Name

    Policy name, which can be customized and must be unique in the service.

    Policy Label

    A label specified for the current policy. You can search for reports and filter policies based on labels.

    topic

    Name of the topic to which the current policy applies. You can enter multiple values.

    The value can contain wildcard characters, such as test, test*, and *.

    The Include policy applies to the current input object, and the Exclude policy applies to objects other than the current input object.

    Description

    Policy description.

    Audit Logging

    Whether to generate an audit log when a request matches the policy.

    • Yes: An audit log is generated whenever an access request matches the policy, regardless of whether the result is Allow or Deny.
    • No: No audit log is generated when an access request matches the policy.

    Allow Conditions

    Permission and exception conditions allowed by a policy. The priority of an exception condition is higher than that of a normal condition.

    In the Select Role, Select Group, and Select User columns, select the role, user group, or user to which you want to assign permissions.

    Click Add Conditions to add the IP address range to which the policy applies and click Add Permissions to add corresponding permissions.

    • Publish: production permission
    • Consume: consumption permission
    • Describe: query permission
    • Create: topic creation permission
    • Delete: topic deletion permission
    • Describe Configs: configuration query permission
    • Alter: permission to change the number of partitions of a topic.
    • Alter Configs: configuration modification permission
    • Select/Deselect All: permission to select or deselect all

    To add multiple permission control rules, click .

    If users or user groups in the current condition need to manage this policy, select Delegate Admin. These users will become the agent administrators. The agent administrators can update and delete this policy and create sub-policies based on the original policy.

    Deny Conditions

    Deny condition. It specifies the permissions and exceptions to be denied in the policy. The configuration method is the same as that of Allow Conditions. Deny conditions take precedence over the allowed conditions configured in Allow Conditions.

    For example, to add the production permission for the test topic of user testuser, configure the following information:

    Figure 1 Kafka permission configuration example
    Table 2 Common permission configuration scenarios

    Scenario

    Role Authorization

    Setting the Kafka administrator permissions

    1. On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
    2. Select the policy whose Policy Name is all - topic and click to edit the policy.
    3. In the Allow Conditions area, select a user from the Select User drop-down list.
    4. Click Add Permissions and select Select/Deselect All.

    Setting the permission for a user to create a topic

    1. Specify a topic name in topic.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Create.

    Setting the permission for a user to delete a topic

    1. Specify a topic name in topic.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Delete.

    Setting the permission for a user to query a topic

    1. Specify a topic name in topic.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Describe and Describe Configs.

    Setting the production permission of a user on a topic

    1. Specify a topic name in topic.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Publish.

    Setting the consumption permission of a user on a topic

    Topic consumption inherently requires offset management. Therefore, the Consume permission for the corresponding ConsumerGroup must be enabled simultaneously. For details, see "Setting the permission for a user to submit ConsumerGroup Offsets".

    1. Specify a topic name in topic.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Consume.

    Setting the permission for a user to expand a topic (by adding partitions)

    1. Specify a topic name in topic.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Alter.

    Setting the permission for a user to modify the topic configuration

    Currently, the Kafka kernel does not support to modify topic parameters based on --bootstrap-server. Therefore, Ranger does not support authentication for this behavior.

    Setting all the management permissions of a user on a cluster

    1. Enter a cluster name and select the cluster on the right side of cluster.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Kafka Admin.

    Setting the permission for a user to create a cluster

    The authentication of the Create operation of a cluster involves the following two scenarios:

    • When the auto.create.topics.enable parameter is enabled in the cluster, a client may send data to a topic that does not yet exist in the service. In this scenario, the system verifies whether the user possesses the Create permission for the cluster.
    • If a user requires widespread topic creation capabilities and is subsequently granted cluster-level Create privilege, that user gains the authorization to create any topic within the entire cluster.
    1. On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
    2. Select the policy whose Policy Name is all - cluster and click to edit the policy.
    3. Enter a cluster name and select the cluster on the right side of cluster.
    4. In the Allow Conditions area, select a user from the Select User drop-down list.
    5. Click Add Permissions and select Create.

    Setting the permission for a user to modify the cluster configuration

    The configuration modification permission allows you to modify the Broker and Broker Logger configurations. Once a user is granted the configuration modification permission, they can view configuration details automatically, even without the explicit configuration query permission. This occurs because the modification permission inherently includes the query permission.

    1. Enter a cluster name and select the cluster on the right side of cluster.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Alter Configs.

    Setting the permission for a user to query the cluster configuration

    In this context, the query operation explicitly targets broker and broker logger information within the cluster. This process does not involve topics.

    1. Enter a cluster name and select the cluster on the right side of cluster.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Describe and Describe Configs.

    Setting the Idempotent Write permission in a cluster for a user

    This permission authenticates the Idempotent Produce behavior of the user's client.

    1. Enter a cluster name and select the cluster on the right side of cluster.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Idempotent Write.

    Setting the permission to migrate partitions in a cluster for a user

    The Alter permission of a cluster can be used to control permissions in the following scenarios:

    1. In the Partition Reassign scenario, migrate the storage directory of replicas.
    2. Elect a leader replica in each partition of the cluster.
    3. Add or delete ACLs.

    Operations in scenarios 1 and 2 are between a controller and broker and between brokers in the cluster. When a cluster is created, this permission is granted to the built-in Kafka user by default. It is meaningless for a common user to be granted with this permission.

    Scenario 3 involves ACL management. ACLs are designed specifically for authorization. Currently, Kafka authorization is delegated to Ranger. Therefore, this scenario is irrelevant as ACL configurations do not take effect.

    1. Enter a cluster name and select the cluster on the right side of cluster.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Alter.

    Setting the Cluster Action permission in a cluster for a user

    This permission controls data synchronization between leader and follower replicas, as well as inter-node communication within the cluster. It is automatically granted to the built-in Kafka user during cluster deployment. Consequently, assigning this cluster-level privilege to a standard user provides no practical value.

    1. Enter a cluster name and select the cluster on the right side of cluster.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Cluster Action.

    Setting the TransactionalId permission for a user

    • The Publish permission is used to authorize client requests that utilize transactional features, such as initializing or aborting a transaction, submitting transactional offsets, and producing transactional data.
    • The Describe permission is used to authorize requests from clients and coordinators that have transactional features enabled.
    • When transactional features are enabled, you are advised to grant both the Publish and Describe permissions to the associated users.
    1. On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
    2. Select the policy whose Policy Name is all - transactionalid and click to edit the policy.
    1. Set transactionalid to a transaction ID.
    2. In the Allow Conditions area, select a user from the Select User drop-down list.
    3. Click Add Permissions and select Publish and Describe.

    Setting the DelegationToken permission for a user

    1. On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
    2. Select the policy whose Policy Name is all - delegationtoken and click to edit the policy.
    3. Set delegationtoken to a delegation token.
    4. In the Allow Conditions area, select a user from the Select User drop-down list.
    5. Click Add Permissions and select Describe.

      Currently, Ranger only controls the Describe permission for delegation tokens, but does not manage their creation, renewal, or expiration privileges.

    Setting the permission for a user to query ConsumerGroup Offsets

    1. On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
    2. Select the policy whose Policy Name is all - consumergroup and click to edit the policy.
    3. In consumergroup, configure the consumer group to be managed.
    4. In the Allow Conditions area, select a user from the Select User drop-down list.
    5. Click Add Permissions and select Describe.

    Setting the permission for a user to submit ConsumerGroup Offsets.

    1. On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
    2. Select the policy whose Policy Name is all - consumergroup and click to edit the policy.
    3. In consumergroup, configure the consumer group to be managed.
    4. In the Allow Conditions area, select a user from the Select User drop-down list.
    5. Click Add Permissions and select Consume.

      When a user is granted the Consume permission for ConsumerGroup, the user is automatically granted the corresponding Describe permission as well.

    Setting the permission for a user to delete ConsumerGroup Offsets

    1. On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
    2. Select the policy whose Policy Name is all - consumergroup and click to edit the policy.
    3. In consumergroup, configure the consumer group to be managed.
    4. In the Allow Conditions area, select a user from the Select User drop-down list.
    5. Click Add Permissions and select Delete.

      When a user is granted with the Delete permission for ConsumerGroup, the user is automatically granted the corresponding Describe permission as well.

  5. (Optional) Configure the policy validity period. Click Add Validity period in the upper right corner of the page, set Start Time and End Time, and select Time Zone. Click Save.

    To add multiple policy validity periods, click . To delete a policy validity period, click .

  6. Click Add to view basic information about the policy in the policy list. After the policy takes effect, check whether the related permissions are normal.

    To disable a policy, click and set the policy to Disabled.

    If a policy is no longer used, click to delete it.

Helpful Links