Merge pull request #14336 from reasonerjt/fix-14303

Add "*" to the claim set in the token for /v2 apis
This commit is contained in:
Wenkai Yin(尹文开) 2021-03-03 11:18:03 +08:00 committed by GitHub
commit ead749b722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -200,6 +200,16 @@ func resourceScopes(ctx context.Context, rc rbac.Resource) map[string]struct{} {
res[s] = struct{}{}
}
}
// "*" is needed in the token for some API in notary server
// see https://github.com/goharbor/harbor/issues/14303#issuecomment-788010900
// and https://github.com/theupdateframework/notary/blob/84287fd8df4f172c9a8289641cdfa355fc86989d/server/server.go#L200
_, ok1 := res["push"]
_, ok2 := res["pull"]
_, ok3 := res["delete"]
if ok1 && ok2 && ok3 {
res["*"] = struct{}{}
}
return res
}

View File

@ -336,6 +336,7 @@ func TestResourceScopes(t *testing.T) {
"scanner-pull": {},
"push": {},
"delete": {},
"*": {},
},
},
{