fix: [restful v2]role operations need dbName (#33283)

issue: #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>
pull/33301/head
PowderLi 2024-05-23 09:51:45 +08:00 committed by GitHub
parent e1bafd7105
commit b9d7145049
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -1514,7 +1514,7 @@ func (h *HandlersV2) listRoles(ctx context.Context, c *gin.Context, anyReq any,
func (h *HandlersV2) describeRole(ctx context.Context, c *gin.Context, anyReq any, dbName string) (interface{}, error) {
getter, _ := anyReq.(RoleNameGetter)
req := &milvuspb.SelectGrantRequest{
Entity: &milvuspb.GrantEntity{Role: &milvuspb.RoleEntity{Name: getter.GetRoleName()}},
Entity: &milvuspb.GrantEntity{Role: &milvuspb.RoleEntity{Name: getter.GetRoleName()}, DbName: dbName},
}
resp, err := wrapperProxy(ctx, c, req, h.checkAuth, false, func(reqCtx context.Context, req any) (interface{}, error) {
return h.proxy.SelectGrant(reqCtx, req.(*milvuspb.SelectGrantRequest))

View File

@ -248,9 +248,12 @@ type UserRoleReq struct {
}
type RoleReq struct {
DbName string `json:"dbName"`
RoleName string `json:"roleName" binding:"required"`
}
func (req *RoleReq) GetDbName() string { return req.DbName }
func (req *RoleReq) GetRoleName() string {
return req.RoleName
}
@ -263,6 +266,8 @@ type GrantReq struct {
DbName string `json:"dbName"`
}
func (req *GrantReq) GetDbName() string { return req.DbName }
type IndexParam struct {
FieldName string `json:"fieldName" binding:"required"`
IndexName string `json:"indexName" binding:"required"`