mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-04 08:24:26 +08:00
fix: options of the maximal number of roles of a user in project (#17033)
Co-authored-by: QIU Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -84,9 +84,6 @@ const (
|
||||
IdentitySyncStatusIdle = "idle"
|
||||
|
||||
MinimalSyncIntervalSeconds = 5 * 60 // 5 minutes
|
||||
|
||||
MaxUserRolesInProject = 10
|
||||
MaxGroupRolesInProject = 5
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -347,8 +347,8 @@ func (manager *SAssignmentManager) ProjectAddUser(ctx context.Context, userCred
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "FetchUserProjectRoleCount")
|
||||
}
|
||||
if roleCnt >= api.MaxUserRolesInProject {
|
||||
return errors.Wrapf(httperrors.ErrTooLarge, "user %s has joined project %s more than %d roles", user.Name, project.Name, roleCnt)
|
||||
if roleCnt >= options.Options.MaxUserRolesInProject {
|
||||
return errors.Wrapf(httperrors.ErrTooLarge, "user %s has joined project %s %d roles more than %d", user.Name, project.Name, roleCnt, options.Options.MaxUserRolesInProject)
|
||||
}
|
||||
err = manager.add(ctx, api.AssignmentUserProject, user.Id, project.Id, role.Id)
|
||||
if err != nil {
|
||||
@@ -498,8 +498,8 @@ func (manager *SAssignmentManager) projectAddGroup(ctx context.Context, userCred
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fetchGroupProjectRoleCount")
|
||||
}
|
||||
if roleCnt >= api.MaxGroupRolesInProject {
|
||||
return errors.Wrapf(httperrors.ErrTooLarge, "group %s has joined project %s more than %d roles", group.Name, project.Name, roleCnt)
|
||||
if roleCnt >= options.Options.MaxGroupRolesInProject {
|
||||
return errors.Wrapf(httperrors.ErrTooLarge, "group %s has joined project %s %d roles more than %d", group.Name, project.Name, roleCnt, options.Options.MaxGroupRolesInProject)
|
||||
}
|
||||
err = manager.add(ctx, api.AssignmentGroupProject, group.Id, project.Id, role.Id)
|
||||
if err != nil {
|
||||
|
||||
@@ -73,6 +73,9 @@ type SKeystoneOptions struct {
|
||||
LdapSearchPageSize uint32 `help:"pagination size for LDAP search" default:"100"`
|
||||
|
||||
ProjectAdminRole string `help:"name of role to be saved as admin user of project" default:"project_owner"`
|
||||
|
||||
MaxUserRolesInProject int `help:"maximal allowed roles of a user in a project" default:"20"`
|
||||
MaxGroupRolesInProject int `help:"maximal allowed roles of a group in a project" default:"20"`
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user