mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 05:35:43 +01:00
fix update robot regression (#17248)
Only check the project id for the project level robot Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
f7ebf20d2e
commit
02c41573d6
@ -303,14 +303,16 @@ func (rAPI *robotAPI) updateV2Robot(ctx context.Context, params operation.Update
|
|||||||
if err := rAPI.validate(params.Robot.Duration, params.Robot.Level, params.Robot.Permissions); err != nil {
|
if err := rAPI.validate(params.Robot.Duration, params.Robot.Level, params.Robot.Permissions); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
projectID, err := getProjectID(ctx, params.Robot.Permissions[0].Namespace)
|
if r.Level != robot.LEVELSYSTEM {
|
||||||
if err != nil {
|
projectID, err := getProjectID(ctx, params.Robot.Permissions[0].Namespace)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if r.ProjectID != projectID {
|
||||||
|
return errors.BadRequestError(nil).WithMessage("cannot update the project id of robot")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if r.Level != robot.LEVELSYSTEM && r.ProjectID != projectID {
|
if err := rAPI.requireAccess(ctx, params.Robot.Level, params.Robot.Permissions[0].Namespace, rbac.ActionUpdate); err != nil {
|
||||||
return errors.BadRequestError(nil).WithMessage("cannot update the project id of robot")
|
|
||||||
}
|
|
||||||
if err := rAPI.requireAccess(ctx, params.Robot.Level, projectID, rbac.ActionUpdate); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if params.Robot.Level != r.Level || params.Robot.Name != r.Name {
|
if params.Robot.Level != r.Level || params.Robot.Name != r.Name {
|
||||||
|
Loading…
Reference in New Issue
Block a user