mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +01:00
Merge pull request #1019 from rikatz/master
Improves namespace validation for Docker Notary integration
This commit is contained in:
commit
32f8c92eb7
@ -105,8 +105,17 @@ func FilterAccess(username string, a *token.ResourceActions) {
|
||||
//clear action list to assign to new acess element after perm check.
|
||||
a.Actions = []string{}
|
||||
if a.Type == "repository" {
|
||||
if strings.Contains(a.Name, "/") { //Only check the permission when the requested image has a namespace, i.e. project
|
||||
projectName := a.Name[0:strings.LastIndex(a.Name, "/")]
|
||||
repoSplit := strings.Split(a.Name, "/")
|
||||
repoLength := len(repoSplit)
|
||||
if repoLength > 1 { //Only check the permission when the requested image has a namespace, i.e. project
|
||||
var projectName string
|
||||
registryURL := os.Getenv("HARBOR_REG_URL")
|
||||
if repoSplit[0] == registryURL {
|
||||
projectName = repoSplit[1]
|
||||
log.Infof("Detected Registry URL in Project Name. Assuming this is a notary request and setting Project Name as %s\n", projectName)
|
||||
} else {
|
||||
projectName = repoSplit[0]
|
||||
}
|
||||
var permission string
|
||||
if len(username) > 0 {
|
||||
isAdmin, err := dao.IsAdminRole(username)
|
||||
|
Loading…
Reference in New Issue
Block a user