Skip to content

Commit 9e8b6ac

Browse files
enhance: [2.4] RBAC custom privilege group (#37560)
Cherry-pick from master pr: #37087, #37558 issue: #37031 --------- Signed-off-by: shaoting-huang <[email protected]>
1 parent 2fbb157 commit 9e8b6ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2914
-211
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
2727
github.com/klauspost/compress v1.17.9
2828
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
29-
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.16-0.20241106083218-955997f1a757
29+
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.16-0.20241110064419-549e4694a7e7
3030
github.com/minio/minio-go/v7 v7.0.73
3131
github.com/pingcap/log v1.1.1-0.20221015072633-39906604fb81
3232
github.com/prometheus/client_golang v1.14.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ github.com/milvus-io/cgosymbolizer v0.0.0-20240722103217-b7dee0e50119 h1:9VXijWu
608608
github.com/milvus-io/cgosymbolizer v0.0.0-20240722103217-b7dee0e50119/go.mod h1:DvXTE/K/RtHehxU8/GtDs4vFtfw64jJ3PaCnFri8CRg=
609609
github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b h1:TfeY0NxYxZzUfIfYe5qYDBzt4ZYRqzUjTR6CvUzjat8=
610610
github.com/milvus-io/gorocksdb v0.0.0-20220624081344-8c5f4212846b/go.mod h1:iwW+9cWfIzzDseEBCCeDSN5SD16Tidvy8cwQ7ZY8Qj4=
611-
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.16-0.20241106083218-955997f1a757 h1:t7B2lyq//BG8S+azUNEfohYxRtU5V9NAy8z0G+QAPo4=
612-
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.16-0.20241106083218-955997f1a757/go.mod h1:/6UT4zZl6awVeXLeE7UGDWZvXj3IWkRsh3mqsn0DiAs=
611+
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.16-0.20241110064419-549e4694a7e7 h1:gq5xxDS2EIYVk3ujO+sQgDWrhTTpsmV+r6Gm7dfFrt8=
612+
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.16-0.20241110064419-549e4694a7e7/go.mod h1:/6UT4zZl6awVeXLeE7UGDWZvXj3IWkRsh3mqsn0DiAs=
613613
github.com/milvus-io/milvus-storage/go v0.0.0-20231227072638-ebd0b8e56d70 h1:Z+sp64fmAOxAG7mU0dfVOXvAXlwRB0c8a96rIM5HevI=
614614
github.com/milvus-io/milvus-storage/go v0.0.0-20231227072638-ebd0b8e56d70/go.mod h1:GPETMcTZq1gLY1WA6Na5kiNAKnq8SEMMiVKUZrM3sho=
615615
github.com/milvus-io/pulsar-client-go v0.6.10 h1:eqpJjU+/QX0iIhEo3nhOqMNXL+TyInAs1IAHZCrCM/A=

internal/datacoord/mock_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,22 @@ func (m *mockRootCoordClient) ListPolicy(ctx context.Context, in *internalpb.Lis
724724
return &internalpb.ListPolicyResponse{Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}}, nil
725725
}
726726

727+
func (m *mockRootCoordClient) CreatePrivilegeGroup(ctx context.Context, req *milvuspb.CreatePrivilegeGroupRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
728+
panic("implement me")
729+
}
730+
731+
func (m *mockRootCoordClient) DropPrivilegeGroup(ctx context.Context, req *milvuspb.DropPrivilegeGroupRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
732+
panic("implement me")
733+
}
734+
735+
func (m *mockRootCoordClient) ListPrivilegeGroups(ctx context.Context, req *milvuspb.ListPrivilegeGroupsRequest, opts ...grpc.CallOption) (*milvuspb.ListPrivilegeGroupsResponse, error) {
736+
panic("implement me")
737+
}
738+
739+
func (m *mockRootCoordClient) OperatePrivilegeGroup(ctx context.Context, req *milvuspb.OperatePrivilegeGroupRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
740+
panic("implement me")
741+
}
742+
727743
type mockHandler struct {
728744
meta *meta
729745
}

internal/datanode/importv2/pool_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ import (
2020
"fmt"
2121
"testing"
2222

23-
"github.com/stretchr/testify/assert"
24-
2523
"github.com/milvus-io/milvus/pkg/config"
2624
"github.com/milvus-io/milvus/pkg/util/paramtable"
25+
"github.com/stretchr/testify/assert"
2726
)
2827

2928
func TestResizePools(t *testing.T) {

internal/distributed/proxy/httpserver/constant.go

+26-20
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import (
99
// v2
1010
const (
1111
// --- category ---
12-
CollectionCategory = "/collections/"
13-
EntityCategory = "/entities/"
14-
PartitionCategory = "/partitions/"
15-
UserCategory = "/users/"
16-
RoleCategory = "/roles/"
17-
IndexCategory = "/indexes/"
18-
AliasCategory = "/aliases/"
19-
ImportJobCategory = "/jobs/import/"
12+
CollectionCategory = "/collections/"
13+
EntityCategory = "/entities/"
14+
PartitionCategory = "/partitions/"
15+
UserCategory = "/users/"
16+
RoleCategory = "/roles/"
17+
IndexCategory = "/indexes/"
18+
AliasCategory = "/aliases/"
19+
ImportJobCategory = "/jobs/import/"
20+
PrivilegeGroupCategory = "/privilege_groups/"
2021

2122
ListAction = "list"
2223
HasAction = "has"
@@ -37,13 +38,15 @@ const (
3738
AdvancedSearchAction = "advanced_search"
3839
HybridSearchAction = "hybrid_search"
3940

40-
UpdatePasswordAction = "update_password"
41-
GrantRoleAction = "grant_role"
42-
RevokeRoleAction = "revoke_role"
43-
GrantPrivilegeAction = "grant_privilege"
44-
RevokePrivilegeAction = "revoke_privilege"
45-
AlterAction = "alter"
46-
GetProgressAction = "get_progress" // deprecated, keep it for compatibility, use `/v2/vectordb/jobs/import/describe` instead
41+
UpdatePasswordAction = "update_password"
42+
GrantRoleAction = "grant_role"
43+
RevokeRoleAction = "revoke_role"
44+
GrantPrivilegeAction = "grant_privilege"
45+
RevokePrivilegeAction = "revoke_privilege"
46+
AlterAction = "alter"
47+
GetProgressAction = "get_progress" // deprecated, keep it for compatibility, use `/v2/vectordb/jobs/import/describe` instead
48+
AddPrivilegesToGroupAction = "add_privileges_to_group"
49+
RemovePrivilegesFromGroupAction = "remove_privileges_from_group"
4750
)
4851

4952
const (
@@ -116,11 +119,14 @@ const (
116119

117120
HTTPReturnRowCount = "rowCount"
118121

119-
HTTPReturnObjectType = "objectType"
120-
HTTPReturnObjectName = "objectName"
121-
HTTPReturnPrivilege = "privilege"
122-
HTTPReturnGrantor = "grantor"
123-
HTTPReturnDbName = "dbName"
122+
HTTPReturnObjectType = "objectType"
123+
HTTPReturnObjectName = "objectName"
124+
HTTPReturnPrivilege = "privilege"
125+
HTTPReturnGrantor = "grantor"
126+
HTTPReturnDbName = "dbName"
127+
HTTPReturnPrivilegeGroupName = "privilegeGroupName"
128+
HTTPReturnPrivileges = "privileges"
129+
HTTPReturnPrivilegeGroups = "privilegeGroups"
124130

125131
DefaultMetricType = metric.COSINE
126132
DefaultPrimaryFieldName = "id"

internal/distributed/proxy/httpserver/handler_v2.go

+86
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ func (h *HandlersV2) RegisterRoutesToV2(router gin.IRouter) {
132132
router.POST(RoleCategory+GrantPrivilegeAction, timeoutMiddleware(wrapperPost(func() any { return &GrantReq{} }, wrapperTraceLog(h.addPrivilegeToRole))))
133133
router.POST(RoleCategory+RevokePrivilegeAction, timeoutMiddleware(wrapperPost(func() any { return &GrantReq{} }, wrapperTraceLog(h.removePrivilegeFromRole))))
134134

135+
// privilege group
136+
router.POST(PrivilegeGroupCategory+CreateAction, timeoutMiddleware(wrapperPost(func() any { return &PrivilegeGroupReq{} }, wrapperTraceLog(h.createPrivilegeGroup))))
137+
router.POST(PrivilegeGroupCategory+DropAction, timeoutMiddleware(wrapperPost(func() any { return &PrivilegeGroupReq{} }, wrapperTraceLog(h.dropPrivilegeGroup))))
138+
router.POST(PrivilegeGroupCategory+ListAction, timeoutMiddleware(wrapperPost(func() any { return &PrivilegeGroupReq{} }, wrapperTraceLog(h.listPrivilegeGroups))))
139+
router.POST(PrivilegeGroupCategory+AddPrivilegesToGroupAction, timeoutMiddleware(wrapperPost(func() any { return &PrivilegeGroupReq{} }, wrapperTraceLog(h.addPrivilegesToGroup))))
140+
router.POST(PrivilegeGroupCategory+RemovePrivilegesFromGroupAction, timeoutMiddleware(wrapperPost(func() any { return &PrivilegeGroupReq{} }, wrapperTraceLog(h.removePrivilegesFromGroup))))
141+
135142
router.POST(IndexCategory+ListAction, timeoutMiddleware(wrapperPost(func() any { return &CollectionNameReq{} }, wrapperTraceLog(h.wrapperCheckDatabase(h.listIndexes)))))
136143
router.POST(IndexCategory+DescribeAction, timeoutMiddleware(wrapperPost(func() any { return &IndexReq{} }, wrapperTraceLog(h.wrapperCheckDatabase(h.describeIndex)))))
137144

@@ -1711,6 +1718,85 @@ func (h *HandlersV2) removePrivilegeFromRole(ctx context.Context, c *gin.Context
17111718
return h.operatePrivilegeToRole(ctx, c, anyReq.(*GrantReq), milvuspb.OperatePrivilegeType_Revoke, dbName)
17121719
}
17131720

1721+
func (h *HandlersV2) createPrivilegeGroup(ctx context.Context, c *gin.Context, anyReq any, dbName string) (interface{}, error) {
1722+
httpReq := anyReq.(*PrivilegeGroupReq)
1723+
req := &milvuspb.CreatePrivilegeGroupRequest{
1724+
GroupName: httpReq.PrivilegeGroupName,
1725+
}
1726+
resp, err := wrapperProxy(ctx, c, req, h.checkAuth, false, "/milvus.proto.milvus.MilvusService/CreatePrivilegeGroup", func(reqCtx context.Context, req any) (interface{}, error) {
1727+
return h.proxy.CreatePrivilegeGroup(reqCtx, req.(*milvuspb.CreatePrivilegeGroupRequest))
1728+
})
1729+
if err == nil {
1730+
HTTPReturn(c, http.StatusOK, wrapperReturnDefault())
1731+
}
1732+
return resp, err
1733+
}
1734+
1735+
func (h *HandlersV2) dropPrivilegeGroup(ctx context.Context, c *gin.Context, anyReq any, dbName string) (interface{}, error) {
1736+
httpReq := anyReq.(*PrivilegeGroupReq)
1737+
req := &milvuspb.DropPrivilegeGroupRequest{
1738+
GroupName: httpReq.PrivilegeGroupName,
1739+
}
1740+
resp, err := wrapperProxy(ctx, c, req, h.checkAuth, false, "/milvus.proto.milvus.MilvusService/DropPrivilegeGroup", func(reqCtx context.Context, req any) (interface{}, error) {
1741+
return h.proxy.DropPrivilegeGroup(reqCtx, req.(*milvuspb.DropPrivilegeGroupRequest))
1742+
})
1743+
if err == nil {
1744+
HTTPReturn(c, http.StatusOK, wrapperReturnDefault())
1745+
}
1746+
return resp, err
1747+
}
1748+
1749+
func (h *HandlersV2) listPrivilegeGroups(ctx context.Context, c *gin.Context, anyReq any, dbName string) (interface{}, error) {
1750+
req := &milvuspb.ListPrivilegeGroupsRequest{}
1751+
resp, err := wrapperProxy(ctx, c, req, h.checkAuth, false, "/milvus.proto.milvus.MilvusService/ListPrivilegeGroups", func(reqCtx context.Context, req any) (interface{}, error) {
1752+
return h.proxy.ListPrivilegeGroups(reqCtx, req.(*milvuspb.ListPrivilegeGroupsRequest))
1753+
})
1754+
if err == nil {
1755+
privGroups := make([]map[string]interface{}, 0)
1756+
for _, group := range resp.(*milvuspb.ListPrivilegeGroupsResponse).PrivilegeGroups {
1757+
privileges := make([]string, len(group.Privileges))
1758+
for i, privilege := range group.Privileges {
1759+
privileges[i] = privilege.Name
1760+
}
1761+
groupInfo := map[string]interface{}{
1762+
HTTPReturnPrivilegeGroupName: group.GroupName,
1763+
HTTPReturnPrivileges: strings.Join(privileges, ","),
1764+
}
1765+
privGroups = append(privGroups, groupInfo)
1766+
}
1767+
HTTPReturn(c, http.StatusOK, gin.H{HTTPReturnCode: merr.Code(nil), HTTPReturnData: gin.H{
1768+
HTTPReturnPrivilegeGroups: privGroups,
1769+
}})
1770+
}
1771+
return resp, err
1772+
}
1773+
1774+
func (h *HandlersV2) addPrivilegesToGroup(ctx context.Context, c *gin.Context, anyReq any, dbName string) (interface{}, error) {
1775+
return h.operatePrivilegeGroup(ctx, c, anyReq, dbName, milvuspb.OperatePrivilegeGroupType_AddPrivilegesToGroup)
1776+
}
1777+
1778+
func (h *HandlersV2) removePrivilegesFromGroup(ctx context.Context, c *gin.Context, anyReq any, dbName string) (interface{}, error) {
1779+
return h.operatePrivilegeGroup(ctx, c, anyReq, dbName, milvuspb.OperatePrivilegeGroupType_RemovePrivilegesFromGroup)
1780+
}
1781+
1782+
func (h *HandlersV2) operatePrivilegeGroup(ctx context.Context, c *gin.Context, anyReq any, dbName string, operateType milvuspb.OperatePrivilegeGroupType) (interface{}, error) {
1783+
httpReq := anyReq.(*PrivilegeGroupReq)
1784+
req := &milvuspb.OperatePrivilegeGroupRequest{
1785+
GroupName: httpReq.PrivilegeGroupName,
1786+
Privileges: lo.Map(httpReq.Privileges, func(p string, _ int) *milvuspb.PrivilegeEntity {
1787+
return &milvuspb.PrivilegeEntity{Name: p}
1788+
}),
1789+
Type: operateType,
1790+
}
1791+
resp, err := wrapperProxy(ctx, c, req, h.checkAuth, false, "/milvus.proto.milvus.MilvusService/OperatePrivilegeGroup", func(reqCtx context.Context, req any) (interface{}, error) {
1792+
return h.proxy.OperatePrivilegeGroup(reqCtx, req.(*milvuspb.OperatePrivilegeGroupRequest))
1793+
})
1794+
if err == nil {
1795+
HTTPReturn(c, http.StatusOK, wrapperReturnDefault())
1796+
}
1797+
return resp, err
1798+
}
1799+
17141800
func (h *HandlersV2) listIndexes(ctx context.Context, c *gin.Context, anyReq any, dbName string) (interface{}, error) {
17151801
collectionGetter, _ := anyReq.(requestutil.CollectionNameGetter)
17161802
indexNames := []string{}

internal/distributed/proxy/httpserver/handler_v2_test.go

+26-2
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,10 @@ func TestMethodGet(t *testing.T) {
897897
Status: &StatusSuccess,
898898
Alias: DefaultAliasName,
899899
}, nil).Once()
900+
mp.EXPECT().ListPrivilegeGroups(mock.Anything, mock.Anything).Return(&milvuspb.ListPrivilegeGroupsResponse{
901+
Status: &StatusSuccess,
902+
PrivilegeGroups: []*milvuspb.PrivilegeGroupInfo{{GroupName: "group1", Privileges: []*milvuspb.PrivilegeEntity{{Name: "*"}}}},
903+
}, nil).Once()
900904

901905
testEngine := initHTTPServerV2(mp, false)
902906
queryTestCases := []rawTestCase{}
@@ -987,6 +991,9 @@ func TestMethodGet(t *testing.T) {
987991
queryTestCases = append(queryTestCases, rawTestCase{
988992
path: versionalV2(AliasCategory, DescribeAction),
989993
})
994+
queryTestCases = append(queryTestCases, rawTestCase{
995+
path: versionalV2(PrivilegeGroupCategory, ListAction),
996+
})
990997

991998
for _, testcase := range queryTestCases {
992999
t.Run(testcase.path, func(t *testing.T) {
@@ -996,7 +1003,8 @@ func TestMethodGet(t *testing.T) {
9961003
`"indexName": "` + DefaultIndexName + `",` +
9971004
`"userName": "` + util.UserRoot + `",` +
9981005
`"roleName": "` + util.RoleAdmin + `",` +
999-
`"aliasName": "` + DefaultAliasName + `"` +
1006+
`"aliasName": "` + DefaultAliasName + `",` +
1007+
`"privilegeGroupName": "pg"` +
10001008
`}`))
10011009
req := httptest.NewRequest(http.MethodPost, testcase.path, bodyReader)
10021010
w := httptest.NewRecorder()
@@ -1037,6 +1045,7 @@ func TestMethodDelete(t *testing.T) {
10371045
mp.EXPECT().DropRole(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Once()
10381046
mp.EXPECT().DropIndex(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Once()
10391047
mp.EXPECT().DropAlias(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Once()
1048+
mp.EXPECT().DropPrivilegeGroup(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Once()
10401049
testEngine := initHTTPServerV2(mp, false)
10411050
queryTestCases := []rawTestCase{}
10421051
queryTestCases = append(queryTestCases, rawTestCase{
@@ -1057,10 +1066,13 @@ func TestMethodDelete(t *testing.T) {
10571066
queryTestCases = append(queryTestCases, rawTestCase{
10581067
path: versionalV2(AliasCategory, DropAction),
10591068
})
1069+
queryTestCases = append(queryTestCases, rawTestCase{
1070+
path: versionalV2(PrivilegeGroupCategory, DropAction),
1071+
})
10601072
for _, testcase := range queryTestCases {
10611073
t.Run(testcase.path, func(t *testing.T) {
10621074
bodyReader := bytes.NewReader([]byte(`{"collectionName": "` + DefaultCollectionName + `", "partitionName": "` + DefaultPartitionName +
1063-
`", "userName": "` + util.UserRoot + `", "roleName": "` + util.RoleAdmin + `", "indexName": "` + DefaultIndexName + `", "aliasName": "` + DefaultAliasName + `"}`))
1075+
`", "userName": "` + util.UserRoot + `", "roleName": "` + util.RoleAdmin + `", "indexName": "` + DefaultIndexName + `", "aliasName": "` + DefaultAliasName + `", "privilegeGroupName": "pg"}`))
10641076
req := httptest.NewRequest(http.MethodPost, testcase.path, bodyReader)
10651077
w := httptest.NewRecorder()
10661078
testEngine.ServeHTTP(w, req)
@@ -1099,6 +1111,8 @@ func TestMethodPost(t *testing.T) {
10991111
mp.EXPECT().CreateIndex(mock.Anything, mock.Anything).Return(commonErrorStatus, nil).Once()
11001112
mp.EXPECT().CreateAlias(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Once()
11011113
mp.EXPECT().AlterAlias(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Once()
1114+
mp.EXPECT().CreatePrivilegeGroup(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Once()
1115+
mp.EXPECT().OperatePrivilegeGroup(mock.Anything, mock.Anything).Return(commonSuccessStatus, nil).Twice()
11021116
mp.EXPECT().ImportV2(mock.Anything, mock.Anything).Return(&internalpb.ImportResponse{
11031117
Status: commonSuccessStatus, JobID: "1234567890",
11041118
}, nil).Once()
@@ -1191,6 +1205,15 @@ func TestMethodPost(t *testing.T) {
11911205
queryTestCases = append(queryTestCases, rawTestCase{
11921206
path: versionalV2(ImportJobCategory, DescribeAction),
11931207
})
1208+
queryTestCases = append(queryTestCases, rawTestCase{
1209+
path: versionalV2(PrivilegeGroupCategory, CreateAction),
1210+
})
1211+
queryTestCases = append(queryTestCases, rawTestCase{
1212+
path: versionalV2(PrivilegeGroupCategory, AddPrivilegesToGroupAction),
1213+
})
1214+
queryTestCases = append(queryTestCases, rawTestCase{
1215+
path: versionalV2(PrivilegeGroupCategory, RemovePrivilegesFromGroupAction),
1216+
})
11941217

11951218
for _, testcase := range queryTestCases {
11961219
t.Run(testcase.path, func(t *testing.T) {
@@ -1201,6 +1224,7 @@ func TestMethodPost(t *testing.T) {
12011224
`"indexParams": [{"indexName": "` + DefaultIndexName + `", "fieldName": "book_intro", "metricType": "L2", "params": {"nlist": 30, "index_type": "IVF_FLAT"}}],` +
12021225
`"userName": "` + util.UserRoot + `", "password": "Milvus", "newPassword": "milvus", "roleName": "` + util.RoleAdmin + `",` +
12031226
`"roleName": "` + util.RoleAdmin + `", "objectType": "Global", "objectName": "*", "privilege": "*",` +
1227+
`"privilegeGroupName": "pg", "privileges": ["create", "drop"],` +
12041228
`"aliasName": "` + DefaultAliasName + `",` +
12051229
`"jobId": "1234567890",` +
12061230
`"files": [["book.json"]]` +

internal/distributed/proxy/httpserver/request_v2.go

+5
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ func (req *RoleReq) GetRoleName() string {
258258
return req.RoleName
259259
}
260260

261+
type PrivilegeGroupReq struct {
262+
PrivilegeGroupName string `json:"privilegeGroupName" binding:"required"`
263+
Privileges []string `json:"privileges"`
264+
}
265+
261266
type GrantReq struct {
262267
RoleName string `json:"roleName" binding:"required"`
263268
ObjectType string `json:"objectType" binding:"required"`

internal/distributed/proxy/service.go

+16
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,22 @@ func (s *Server) RestoreRBAC(ctx context.Context, req *milvuspb.RestoreRBACMetaR
10601060
return s.proxy.RestoreRBAC(ctx, req)
10611061
}
10621062

1063+
func (s *Server) CreatePrivilegeGroup(ctx context.Context, req *milvuspb.CreatePrivilegeGroupRequest) (*commonpb.Status, error) {
1064+
return s.proxy.CreatePrivilegeGroup(ctx, req)
1065+
}
1066+
1067+
func (s *Server) DropPrivilegeGroup(ctx context.Context, req *milvuspb.DropPrivilegeGroupRequest) (*commonpb.Status, error) {
1068+
return s.proxy.DropPrivilegeGroup(ctx, req)
1069+
}
1070+
1071+
func (s *Server) ListPrivilegeGroups(ctx context.Context, req *milvuspb.ListPrivilegeGroupsRequest) (*milvuspb.ListPrivilegeGroupsResponse, error) {
1072+
return s.proxy.ListPrivilegeGroups(ctx, req)
1073+
}
1074+
1075+
func (s *Server) OperatePrivilegeGroup(ctx context.Context, req *milvuspb.OperatePrivilegeGroupRequest) (*commonpb.Status, error) {
1076+
return s.proxy.OperatePrivilegeGroup(ctx, req)
1077+
}
1078+
10631079
func (s *Server) RefreshPolicyInfoCache(ctx context.Context, req *proxypb.RefreshPolicyInfoCacheRequest) (*commonpb.Status, error) {
10641080
return s.proxy.RefreshPolicyInfoCache(ctx, req)
10651081
}

internal/distributed/rootcoord/client/client.go

+48
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,51 @@ func (c *Client) RestoreRBAC(ctx context.Context, in *milvuspb.RestoreRBACMetaRe
694694
return client.RestoreRBAC(ctx, in)
695695
})
696696
}
697+
698+
func (c *Client) CreatePrivilegeGroup(ctx context.Context, in *milvuspb.CreatePrivilegeGroupRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
699+
in = typeutil.Clone(in)
700+
commonpbutil.UpdateMsgBase(
701+
in.GetBase(),
702+
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.sess.ServerID)),
703+
)
704+
705+
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
706+
return client.CreatePrivilegeGroup(ctx, in)
707+
})
708+
}
709+
710+
func (c *Client) DropPrivilegeGroup(ctx context.Context, in *milvuspb.DropPrivilegeGroupRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
711+
in = typeutil.Clone(in)
712+
commonpbutil.UpdateMsgBase(
713+
in.GetBase(),
714+
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.sess.ServerID)),
715+
)
716+
717+
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
718+
return client.DropPrivilegeGroup(ctx, in)
719+
})
720+
}
721+
722+
func (c *Client) ListPrivilegeGroups(ctx context.Context, in *milvuspb.ListPrivilegeGroupsRequest, opts ...grpc.CallOption) (*milvuspb.ListPrivilegeGroupsResponse, error) {
723+
in = typeutil.Clone(in)
724+
commonpbutil.UpdateMsgBase(
725+
in.GetBase(),
726+
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.sess.ServerID)),
727+
)
728+
729+
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*milvuspb.ListPrivilegeGroupsResponse, error) {
730+
return client.ListPrivilegeGroups(ctx, in)
731+
})
732+
}
733+
734+
func (c *Client) OperatePrivilegeGroup(ctx context.Context, in *milvuspb.OperatePrivilegeGroupRequest, opts ...grpc.CallOption) (*commonpb.Status, error) {
735+
in = typeutil.Clone(in)
736+
commonpbutil.UpdateMsgBase(
737+
in.GetBase(),
738+
commonpbutil.FillMsgBaseFromClient(paramtable.GetNodeID(), commonpbutil.WithTargetID(c.sess.ServerID)),
739+
)
740+
741+
return wrapGrpcCall(ctx, c, func(client rootcoordpb.RootCoordClient) (*commonpb.Status, error) {
742+
return client.OperatePrivilegeGroup(ctx, in)
743+
})
744+
}

0 commit comments

Comments
 (0)