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
- Log in to the Ranger web UI as the Ranger administrator. For details, see Logging In to the Ranger Web UI.
- On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
- Click Add New Policy to add a Kafka permission control policy.
- 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
- On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
- Select the policy whose Policy Name is all - topic and click
to edit the policy. - In the Allow Conditions area, select a user from the Select User drop-down list.
- Click Add Permissions and select Select/Deselect All.
Setting the permission for a user to create a topic
- Specify a topic name in topic.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- Click Add Permissions and select Create.
Setting the permission for a user to delete a topic
- Specify a topic name in topic.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- Click Add Permissions and select Delete.
Setting the permission for a user to query a topic
- Specify a topic name in topic.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- Click Add Permissions and select Describe and Describe Configs.
Setting the production permission of a user on a topic
- Specify a topic name in topic.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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".
- Specify a topic name in topic.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- Click Add Permissions and select Consume.
Setting the permission for a user to expand a topic (by adding partitions)
- Specify a topic name in topic.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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
- Enter a cluster name and select the cluster on the right side of cluster.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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.
- On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
- Select the policy whose Policy Name is all - cluster and click
to edit the policy. - Enter a cluster name and select the cluster on the right side of cluster.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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.
- Enter a cluster name and select the cluster on the right side of cluster.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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.
- Enter a cluster name and select the cluster on the right side of cluster.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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.
- Enter a cluster name and select the cluster on the right side of cluster.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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:
- In the Partition Reassign scenario, migrate the storage directory of replicas.
- Elect a leader replica in each partition of the cluster.
- 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.
- Enter a cluster name and select the cluster on the right side of cluster.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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.
- Enter a cluster name and select the cluster on the right side of cluster.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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.
- On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
- Select the policy whose Policy Name is all - transactionalid and click
to edit the policy.
- Set transactionalid to a transaction ID.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- Click Add Permissions and select Publish and Describe.
Setting the DelegationToken permission for a user
- On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
- Select the policy whose Policy Name is all - delegationtoken and click
to edit the policy. - Set delegationtoken to a delegation token.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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
- On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
- Select the policy whose Policy Name is all - consumergroup and click
to edit the policy. - In consumergroup, configure the consumer group to be managed.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- Click Add Permissions and select Describe.
Setting the permission for a user to submit ConsumerGroup Offsets.
- On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
- Select the policy whose Policy Name is all - consumergroup and click
to edit the policy. - In consumergroup, configure the consumer group to be managed.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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
- On the home page, click the component plug-in name in the KAFKA area, for example, Kafka.
- Select the policy whose Policy Name is all - consumergroup and click
to edit the policy. - In consumergroup, configure the consumer group to be managed.
- In the Allow Conditions area, select a user from the Select User drop-down list.
- 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.
- (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
. - 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
- For details about the priorities of different Ranger policies, see Condition Priorities of the Ranger Permission Policy.
- To view information about permission objects in Ranger, such as users, user groups, and roles, see Viewing Ranger User Permission Synchronization Information.
- You can create new users for an MRS cluster in MRS Manager. For details, see Creating an MRS Cluster User.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot