Skip to content

Commit b9d7145

Browse files
authored
fix: [restful v2]role operations need dbName (milvus-io#33283)
issue: milvus-io#33220 use dbName as part of privilege entity, so 1. grant / revoke a privilege need dbName 2. we can describe the privileges of the role which belong to one special database Signed-off-by: PowderLi <min.li@zilliz.com>
1 parent e1bafd7 commit b9d7145

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

internal/distributed/proxy/httpserver/handler_v2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ func (h *HandlersV2) listRoles(ctx context.Context, c *gin.Context, anyReq any,
15141514
func (h *HandlersV2) describeRole(ctx context.Context, c *gin.Context, anyReq any, dbName string) (interface{}, error) {
15151515
getter, _ := anyReq.(RoleNameGetter)
15161516
req := &milvuspb.SelectGrantRequest{
1517-
Entity: &milvuspb.GrantEntity{Role: &milvuspb.RoleEntity{Name: getter.GetRoleName()}},
1517+
Entity: &milvuspb.GrantEntity{Role: &milvuspb.RoleEntity{Name: getter.GetRoleName()}, DbName: dbName},
15181518
}
15191519
resp, err := wrapperProxy(ctx, c, req, h.checkAuth, false, func(reqCtx context.Context, req any) (interface{}, error) {
15201520
return h.proxy.SelectGrant(reqCtx, req.(*milvuspb.SelectGrantRequest))

internal/distributed/proxy/httpserver/request_v2.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,12 @@ type UserRoleReq struct {
248248
}
249249

250250
type RoleReq struct {
251+
DbName string `json:"dbName"`
251252
RoleName string `json:"roleName" binding:"required"`
252253
}
253254

255+
func (req *RoleReq) GetDbName() string { return req.DbName }
256+
254257
func (req *RoleReq) GetRoleName() string {
255258
return req.RoleName
256259
}
@@ -263,6 +266,8 @@ type GrantReq struct {
263266
DbName string `json:"dbName"`
264267
}
265268

269+
func (req *GrantReq) GetDbName() string { return req.DbName }
270+
266271
type IndexParam struct {
267272
FieldName string `json:"fieldName" binding:"required"`
268273
IndexName string `json:"indexName" binding:"required"`

0 commit comments

Comments
 (0)