Skip to main content
Version: User Guides (Cloud)

Manage Cluster User (SDK)

In Zilliz Cloud, you can create cluster users and assign them cluster roles to define the privileges, achieving data security.

This guide will walk you through how to create a cluster user, grant a role to a user, revoke a role from a user, and finally drop a user. For details about cluster roles, refer to Manage Cluster Roles (Console).

Create a user

The following example shows how to create a user with the username user_1 and the password P@ssw0rd. The username and password for the user must follow these rules:

  • Username: Must start with a letter and can only include uppercase or lowercase letters, numbers, and underscores.

  • Password: Must be 8-64 characters long and must include three of the following: uppercase letters, lowercase letters, numbers, and special characters.

from pymilvus import MilvusClient

client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

client.create_user(user_name="user_1", password="P@ssw0rd")

List users

After creating several users, you can list and view all existing users.

from pymilvus import MilvusClient

client.list_users()

Below is an example output. root is the default user automatically generated. user_1 is the new user that is just created.

['root', 'user_1']

Grant a role to a user

The following example demonstrates how to grant the role role_a to the user user_1.

from pymilvus import MilvusClient

client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

client.grant_role(user_name="user_1", role_name="role_a")

Describe user

Once you grant a role to a user, you can check if the grant operation is successful via the describe_user() method.

The following example demonstrates how to check the role(s) of the user user_1.

from pymilvus import MilvusClient

client.describe_user(user_name="user_1")

Below is an example output.

{'user_name': 'user_1', 'roles': 'role_a'}

Revoke a role

You can also revoke a role that has been assigned to a user.

The following example demonstrates how to revoke the role role_a assigned to the user user_1.

from pymilvus import MilvusClient

client.revoke_role(
user_name='user_1',
role_name='role_a'
)

Drop user

The following example demonstrates how to drop the user user_1.

📘Notes

The root user cannot be dropped.

from pymilvus import MilvusClient

client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

# create a user
client.drop_user(user_name="user_1")

Once the user is dropped, you can list all existing users to check if the drop operation is successful.

from pymilvus import MilvusClient

client.list_users()

Below is an example output. There is no user_1 in the list. The drop operation is successful.

['root']