🚀 免費嘗試 Zilliz Cloud,完全托管的 Milvus,體驗速度提升 10 倍!立即嘗試

milvus-logo
LFAI
主頁

建立特權群組

為了簡化授予特權的流程,建議您將多個特權合併為一個特權群組。

特權群組與特權

特權群組由多個特權組成。

Privilege group illustrated 特權群組說明

如上圖所示,假設您需要賦予一個角色三種不同的權限。

  • 如果不使用特權群組,則需要授予三次特權。

  • 如果使用特權群組,則只需建立特權群組,並將三種特權加入此特權群組,然後將特權群組授權給角色 A。

透過使用特權群組,您可以批量授予角色多項特權。

內建的特權群組

為了易於使用,Milvus 在集合、資料庫和實例層面上提供了共 9 個內建的權限:COLL_RO、COLL_RW、COLL_ADMIN、DB_RO、DB_RW、DB_Admin、Cluster_RO、Cluster_RW 和 Cluster_Admin。

這三層內建的權限群組沒有階級關係。在實體層級設定權限群組,並不會自動設定該實體下所有資料庫和資料集的權限。資料庫和資料集層級的權限需要手動設定。

下表說明每個內建權限群組所包含的權限。

資料集層級

  • COLL_RO: 包含讀取集合資料的權限。

  • COLL_RW:包含讀取和寫入收集資料的權限。

  • COLL_ADMIN:包含讀取和寫入集合資料以及管理集合的權限。

下表列出了集合層級的三個內建權限群組所包含的特定權限。

**權限**

**僅限集合讀取**

僅讀取集合資料** **寫入集合資料** **讀取集合資料**

**集合管理員**

查詢

✔️

✔️

✔️

搜尋

✔️

✔️

✔️

索引詳細資料

✔️

✔️

✔️

GetFlushState

✔️

✔️

✔️

取得載入狀態

✔️

✔️

✔️

GetLoadingProgress

✔️

✔️

✔️

HasPartition

✔️

✔️

✔️

顯示分區

✔️

✔️

✔️

列出別名

✔️

✔️

✔️

描述集合

✔️

✔️

✔️

描述別名

✔️

✔️

✔️

取得統計資料

✔️

✔️

✔️

建立索引

✔️

✔️

下拉索引

✔️

✔️

建立分區

✔️

✔️

DropPartition

✔️

✔️

載入

✔️

✔️

釋放

✔️

✔️

插入

✔️

✔️

刪除

✔️

✔️

上傳

✔️

✔️

輸入

✔️

✔️

同花順

✔️

✔️

壓實

✔️

✔️

負載平衡

✔️

✔️

建立別名

✔️

刪除別名

✔️

資料庫層級

  • DB_RO:包含讀取資料庫資料的權限

  • DB_RW:包含讀取及寫入資料庫資料的權限

  • DB_Admin:包括讀取和寫入資料庫資料以及管理資料庫的權限。

下表列出了資料庫層級的三個內建權限群組所包含的特定權限。

**權限**

**僅讀取資料庫**

**資料庫讀寫**

**資料庫管理員**

顯示資料庫

✔️

✔️

✔️

描述資料庫

✔️

✔️

✔️

建立集合

✔️

丟棄收藏集

✔️

改變資料庫

✔️

✔️

群集層級

  • Cluster_RO: 包含讀取實體資料的權限

  • Cluster_RW: 包含讀取和寫入實體資料的權限

  • Cluster_Admin: 包含讀寫實體資料和管理實體的權限。

下表列出了实例级别的三个内置权限组所包含的特定权限。

**權限**

**僅限群集讀取**

**叢集讀取寫入**

**簇管理**

列出資料庫

✔️

✔️

✔️

重新命名資料庫

✔️

建立所有權

✔️

更新使用者

✔️

刪除所有權

✔️

選擇所有權

✔️

✔️

✔️

管理所有權

✔️

選擇使用者

✔️

✔️

✔️

備份RBAC

✔️

還原RBAC

✔️

建立資源群組

✔️

刪除資源群組

✔️

更新資源群組

✔️

✔️

描述資源群組

✔️

✔️

✔️

列出資源群組

✔️

✔️

✔️

傳輸節點

✔️

✔️

傳輸複製

✔️

✔️

建立資料庫

✔️

刪除資料庫

✔️

全部清除

✔️

✔️

建立權限群組

✔️

刪除權限群組

✔️

ListPrivilegeGroups

✔️

操作特權群組

✔️

程序

您可以建立特權群組,然後將特權加入特權群組。

建立特權群組

以下範例示範如何建立一個名為privilege_group_1 的特權群組。

from pymilvus import MilvusClient
client.create_privileg_group(group_name='privilege_group_1'
import io.milvus.v2.service.rbac.request.CreatePrivilegeGroupReq;

client.createPrivilegeGroup(CreatePrivilegeGroupReq.builder()
        .groupName("privilege_group_1")
        .build());

import "github.com/milvus-io/milvus-sdk-go/v2/client"

client.CreatePrivilegeGroup(context.Background(), "privilege_group_1")

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/privilege_groups/create" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
    "privilegeGroupName":"privilege_group_1"
}'

在特權群組中加入特權

下面的示例演示了如何將權限PrivilegeBackupRBACPrivilegeRestoreRBAC 添加到剛剛創建的權限組privilege_group_1 中。

from pymilvus import MilvusClient
client.add_privileges_to_group(group_name='privilege_group_1', privileges=['Query', 'Search'])

import io.milvus.v2.service.rbac.request.AddPrivilegesToGroupReq;

client.addPrivilegesToGroup(AddPrivilegesToGroupReq.builder()
        .groupName("privilege_group_1")
        .privileges(Arrays.asList("Query", "Search"))
        .build());

import "github.com/milvus-io/milvus-sdk-go/v2/client"

client.AddPrivilegesToGroup(context.Background(), "privilege_group_1", []string{"Query", "Search"})

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/privilege_groups/add_privileges_to_group" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
    "privilegeGroupName":"privilege_group_1",
    "privileges":["Query", "Search"]
}'

從特權群組移除特權

以下範例示範如何從特權群組privilege_group_1 移除特權PrivilegeRestoreRBAC

from pymilvus import MilvusClient
client.remove_privileges_from_group(group_name='privilege_group_1', privileges='Search')

import io.milvus.v2.service.rbac.request.RemovePrivilegesFromGroupReq;

client.removePrivilegesFromGroup(RemovePrivilegesFromGroupReq.builder()
        .groupName("privilege_group_1")
        .privileges(Collections.singletonList("Search"))
        .build());

import "github.com/milvus-io/milvus-sdk-go/v2/client"

client.RemovePrivilegesFromGroup(context.Background(), "privilege_group_1", []string{"Search"})

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/privilege_groups/remove_privileges_from_group" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
    "privilegeGroupName":"privilege_group_1",
    "privileges":["Search"]
}'

列出特權群組

以下範例說明如何列出所有現有的特權群組。

from pymilvus import MilvusClient
client.list_privilege_groups()

import io.milvus.v2.service.rbac.PrivilegeGroup;
import io.milvus.v2.service.rbac.request.ListPrivilegeGroupsReq;
import io.milvus.v2.service.rbac.response.ListPrivilegeGroupsResp;

ListPrivilegeGroupsResp resp = client.listPrivilegeGroups(ListPrivilegeGroupsReq.builder()
        .build());
List<PrivilegeGroup> groups = resp.getPrivilegeGroups();

import "github.com/milvus-io/milvus-sdk-go/v2/client"

client.ListPrivilegeGroups(context.Background())

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/privilege_groups/list" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{}'

以下是一個輸出範例。

PrivilegeGroupItem: <privilege_group:privilege_group_1>, <privileges:('Search', 'Query')>

刪除特權群組

以下範例說明如何刪除特權群組privilege_group_1

from pymilvus import MilvusClient
client.drop_privilege_group(group_name='privilege_group_1')

import io.milvus.v2.service.rbac.request.DropPrivilegeGroupReq;

client.dropPrivilegeGroup(DropPrivilegeGroupReq.builder()
        .groupName("privilege_group_1")
        .build());

import "github.com/milvus-io/milvus-sdk-go/v2/client"

client.DropPrivilegeGroup(context.Background(), "privilege_group_1")

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/privilege_groups/drop" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
    "privilegeGroupName":"privilege_group_1"
}'

免費嘗試托管的 Milvus

Zilliz Cloud 無縫接入,由 Milvus 提供動力,速度提升 10 倍。

開始使用
反饋

這個頁面有幫助嗎?