mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
enhance: [2.4] add list aliases privilege into public role and fix typo (#38208)
cherry-pick from master: https://github.com/milvus-io/milvus/pull/38176, https://github.com/milvus-io/milvus/pull/38195 related issue: https://github.com/milvus-io/milvus/issues/37031 --------- Signed-off-by: shaoting-huang <shaoting.huang@zilliz.com>
This commit is contained in:
parent
319f5494cd
commit
febed0abb7
@ -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
|
||||
|
||||
@ -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")
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user