mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 16:25:37 +00:00
Improve Project Name handling for Docker Notary requests
This commit is contained in:
parent
4dd5593bd5
commit
dbcbe80084
|
@ -105,8 +105,15 @@ func FilterAccess(username string, a *token.ResourceActions) {
|
||||||
//clear action list to assign to new acess element after perm check.
|
//clear action list to assign to new acess element after perm check.
|
||||||
a.Actions = []string{}
|
a.Actions = []string{}
|
||||||
if a.Type == "repository" {
|
if a.Type == "repository" {
|
||||||
if strings.Contains(a.Name, "/") { //Only check the permission when the requested image has a namespace, i.e. project
|
repoSplit := strings.Split(a.Name, "/")
|
||||||
projectName := a.Name[0:strings.LastIndex(a.Name, "/")]
|
repoLength := len(repoSplit)
|
||||||
|
if repoLength > 0 { //Only check the permission when the requested image has a namespace, i.e. project
|
||||||
|
var projectName string
|
||||||
|
if repoLength > 2 { //If the repo contains more than 1 separation (as privateregistry.local/library/alpine) consider the second item from array (library)
|
||||||
|
projectName = repoSplit[1]
|
||||||
|
} else { // Otherwise (only library/alpine) consider the first item from array (library)
|
||||||
|
projectName = repoSplit[0]
|
||||||
|
}
|
||||||
var permission string
|
var permission string
|
||||||
if len(username) > 0 {
|
if len(username) > 0 {
|
||||||
isAdmin, err := dao.IsAdminRole(username)
|
isAdmin, err := dao.IsAdminRole(username)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user