mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
fix system label resource (#19621)
Make sure robot can use rbac.Resource(label) to access system level label Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
969dd1be66
commit
e6900301ce
@ -23,7 +23,6 @@ import (
|
|||||||
|
|
||||||
"github.com/goharbor/harbor/src/common"
|
"github.com/goharbor/harbor/src/common"
|
||||||
"github.com/goharbor/harbor/src/common/rbac"
|
"github.com/goharbor/harbor/src/common/rbac"
|
||||||
"github.com/goharbor/harbor/src/common/rbac/system"
|
|
||||||
"github.com/goharbor/harbor/src/controller/project"
|
"github.com/goharbor/harbor/src/controller/project"
|
||||||
"github.com/goharbor/harbor/src/lib"
|
"github.com/goharbor/harbor/src/lib"
|
||||||
"github.com/goharbor/harbor/src/lib/errors"
|
"github.com/goharbor/harbor/src/lib/errors"
|
||||||
@ -193,8 +192,7 @@ func (lAPI *labelAPI) DeleteLabel(ctx context.Context, params operation.DeleteLa
|
|||||||
func (lAPI *labelAPI) requireAccess(ctx context.Context, label *pkg_model.Label, action rbac.Action, subresources ...rbac.Resource) error {
|
func (lAPI *labelAPI) requireAccess(ctx context.Context, label *pkg_model.Label, action rbac.Action, subresources ...rbac.Resource) error {
|
||||||
switch label.Scope {
|
switch label.Scope {
|
||||||
case common.LabelScopeGlobal:
|
case common.LabelScopeGlobal:
|
||||||
resource := system.NewNamespace().Resource(rbac.ResourceLabel)
|
return lAPI.RequireSystemAccess(ctx, action, rbac.ResourceLabel)
|
||||||
return lAPI.RequireSystemAccess(ctx, action, resource)
|
|
||||||
case common.LabelScopeProject:
|
case common.LabelScopeProject:
|
||||||
if len(subresources) == 0 {
|
if len(subresources) == 0 {
|
||||||
subresources = append(subresources, rbac.ResourceLabel)
|
subresources = append(subresources, rbac.ResourceLabel)
|
||||||
|
Loading…
Reference in New Issue
Block a user