[management] Prevent removal of All group from peers during user groups propagation (#2410)

* Prevent removal of "All" group from peers

* Prevent adding "All" group to users and setup keys

* Refactor setup key group validation
This commit is contained in:
Bethuel Mmbaga
2024-08-12 13:48:05 +03:00
committed by GitHub
parent 15eb752a7d
commit 539480a713
4 changed files with 59 additions and 11 deletions

View File

@@ -944,10 +944,14 @@ func validateUserUpdate(account *Account, initiatorUser, oldUser, update *User)
}
for _, newGroupID := range update.AutoGroups {
if _, ok := account.Groups[newGroupID]; !ok {
group, ok := account.Groups[newGroupID]
if !ok {
return status.Errorf(status.InvalidArgument, "provided group ID %s in the user %s update doesn't exist",
newGroupID, update.Id)
}
if group.Name == "All" {
return status.Errorf(status.InvalidArgument, "can't add All group to the user")
}
}
return nil