Skip to content

Commit

Permalink
enhance: [2.4] add list aliases privilege into public role and fix ty…
Browse files Browse the repository at this point in the history
…po (#38208)

cherry-pick from master: #38176,
#38195
related issue: #37031

---------

Signed-off-by: shaoting-huang <[email protected]>
  • Loading branch information
shaoting-huang authored Dec 4, 2024
1 parent 319f549 commit febed0a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/proxy/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -5276,7 +5276,7 @@ func (node *Proxy) validateOperatePrivilegeV2Params(req *milvuspb.OperatePrivile
return err
}
}
if err := ValidateObjectName(req.CollectionName); err != nil {
if err := ValidateCollectionName(req.CollectionName); err != nil {
return err
}
return nil
Expand Down
7 changes: 7 additions & 0 deletions internal/proxy/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,13 @@ func ValidateObjectName(entity string) error {
return validateName(entity, "object name")
}

func ValidateCollectionName(entity string) error {
if util.IsAnyWord(entity) {
return nil
}
return validateName(entity, "collection name")
}

func ValidateObjectType(entity string) error {
return validateName(entity, "ObjectType")
}
Expand Down
1 change: 1 addition & 0 deletions internal/rootcoord/root_coord.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ func (c *Core) initPublicRolePrivilege() error {
// grant privileges for the public role
globalPrivileges := []string{
commonpb.ObjectPrivilege_PrivilegeDescribeCollection.String(),
commonpb.ObjectPrivilege_PrivilegeListAliases.String(),
}
collectionPrivileges := []string{
commonpb.ObjectPrivilege_PrivilegeIndexDetail.String(),
Expand Down
2 changes: 1 addition & 1 deletion internal/rootcoord/root_coord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,7 @@ func TestCore_InitRBAC(t *testing.T) {
meta := mockrootcoord.NewIMetaTable(t)
c := newTestCore(withHealthyCode(), withMeta(meta))
meta.EXPECT().CreateRole(mock.Anything, mock.Anything).Return(nil).Twice()
meta.EXPECT().OperatePrivilege(mock.Anything, mock.Anything, mock.Anything).Return(nil).Twice()
meta.EXPECT().OperatePrivilege(mock.Anything, mock.Anything, mock.Anything).Return(nil).Times(3)

Params.Save(Params.RoleCfg.Enabled.Key, "false")
Params.Save(Params.ProxyCfg.EnablePublicPrivilege.Key, "true")
Expand Down

0 comments on commit febed0a

Please sign in to comment.