mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-18 22:57:38 +01:00
Merge pull request #11569 from ywk253100/200410_replication
Add "delete" into the action map if the action in token is "*"
This commit is contained in:
commit
81a4e7d468
@ -94,13 +94,16 @@ func New(ctx context.Context, name string, access []*registry_token.ResourceActi
|
|||||||
}
|
}
|
||||||
actionMap := make(map[types.Action]struct{})
|
actionMap := make(map[types.Action]struct{})
|
||||||
for _, a := range ac.Actions {
|
for _, a := range ac.Actions {
|
||||||
if a == "pull" || a == "*" {
|
switch a {
|
||||||
|
case "pull":
|
||||||
actionMap[rbac.ActionPull] = struct{}{}
|
actionMap[rbac.ActionPull] = struct{}{}
|
||||||
}
|
case "push":
|
||||||
if a == "push" || a == "*" {
|
|
||||||
actionMap[rbac.ActionPush] = struct{}{}
|
actionMap[rbac.ActionPush] = struct{}{}
|
||||||
}
|
case "*":
|
||||||
if a == "scanner-pull" {
|
actionMap[rbac.ActionPull] = struct{}{}
|
||||||
|
actionMap[rbac.ActionPush] = struct{}{}
|
||||||
|
actionMap[rbac.ActionDelete] = struct{}{}
|
||||||
|
case "scanner-pull":
|
||||||
actionMap[rbac.ActionScannerPull] = struct{}{}
|
actionMap[rbac.ActionScannerPull] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,11 @@ func TestAll(t *testing.T) {
|
|||||||
action: rbac.ActionPush,
|
action: rbac.ActionPush,
|
||||||
expect: true,
|
expect: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resource: rbac.NewProjectNamespace(2).Resource(rbac.ResourceRepository),
|
||||||
|
action: rbac.ActionDelete,
|
||||||
|
expect: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
resource: rbac.NewProjectNamespace(2).Resource(rbac.ResourceRepository),
|
resource: rbac.NewProjectNamespace(2).Resource(rbac.ResourceRepository),
|
||||||
action: rbac.ActionScannerPull,
|
action: rbac.ActionScannerPull,
|
||||||
|
Loading…
Reference in New Issue
Block a user