Skip to content
API Reference Zilliz Cloud Milvus Attu

User & Role Management

This guide covers user and role management, including authentication, authorization, and RBAC operations.

Create a new user:

await client.createUser({
username: 'newuser',
password: 'securepassword',
});

Update user password:

await client.updateUser({
username: 'newuser',
password: 'newpassword',
});

Delete a user:

await client.deleteUser({
username: 'newuser',
});

List all users:

const result = await client.listUsers();
console.log('Users:', result.usernames);

Get user information:

const user = await client.describeUser({
username: 'newuser',
});
console.log('User info:', user);

Create a new role:

await client.createRole({
roleName: 'admin',
});

Delete a role:

await client.dropRole({
roleName: 'admin',
});

List all roles:

const result = await client.listRoles();
console.log('Roles:', result.results);

Get role information:

const role = await client.describeRole({
roleName: 'admin',
});
console.log('Role info:', role);

Check if a role exists:

const hasRole = await client.hasRole({
roleName: 'admin',
});
console.log('Role exists:', hasRole.hasRole);

Assign a user to a role:

await client.addUserToRole({
username: 'newuser',
roleName: 'admin',
});

Remove a user from a role:

await client.removeUserFromRole({
username: 'newuser',
roleName: 'admin',
});

Grant privileges to a role:

await client.grantPrivilege({
roleName: 'admin',
object: 'Collection',
objectName: 'my_collection',
privilegeName: 'Load',
});

Revoke privileges from a role:

await client.revokePrivilege({
roleName: 'admin',
object: 'Collection',
objectName: 'my_collection',
privilegeName: 'Load',
});

Get granted privileges:

const grants = await client.selectGrant({
roleName: 'admin',
object: 'Collection',
objectName: 'my_collection',
});
console.log('Grants:', grants.entities);

List all grants for a role:

const grants = await client.listGrants({
roleName: 'admin',
});
console.log('Grants:', grants.entities);

Create a privilege group:

await client.createPrivilegeGroup({
groupName: 'readonly_group',
});

Delete a privilege group:

await client.dropPrivilegeGroup({
groupName: 'readonly_group',
});

List all privilege groups:

const groups = await client.listPrivilegeGroups();
console.log('Groups:', groups.group_names);

Add privileges to a group:

await client.addPrivilegesToGroup({
groupName: 'readonly_group',
privileges: [
{
object: 'Collection',
objectName: '*',
privilegeName: 'DescribeCollection',
},
],
});

Remove privileges from a group:

await client.removePrivilegesFromGroup({
groupName: 'readonly_group',
privileges: [
{
object: 'Collection',
objectName: '*',
privilegeName: 'DescribeCollection',
},
],
});

Grant privileges using RBAC v2:

await client.grantPrivilegeV2({
roleName: 'admin',
privileges: [
{
object: 'Collection',
objectName: '*',
privilegeName: 'Load',
},
],
});

Revoke privileges using RBAC v2:

await client.revokePrivilegeV2({
roleName: 'admin',
privileges: [
{
object: 'Collection',
objectName: '*',
privilegeName: 'Load',
},
],
});

Backup RBAC configuration:

const backup = await client.backupRBAC();
console.log('Backup:', backup);

Restore RBAC configuration:

await client.restoreRBAC({
backup: backupData,
});

Drop all roles (use with caution):

const results = await client.dropAllRoles();
console.log('Dropped roles:', results);

Supported privilege objects:

  • Collection
  • Partition
  • Index
  • Database
  • Global

Common privilege names:

  • Create
  • Drop
  • Describe
  • Show
  • Load
  • Release
  • Insert
  • Delete
  • Update
  • Search
  • Query
  • Flush
  • Compact
  1. Principle of least privilege: Grant only necessary privileges
  2. Use roles: Group users into roles for easier management
  3. Regular audits: Review user and role assignments regularly
  4. Secure passwords: Enforce strong password policies
  5. Backup RBAC: Regularly backup RBAC configuration