Skip to content

Commit

Permalink
update for harbor v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cafeliker committed Jul 7, 2020
1 parent eb82cb9 commit 1d368e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/common/rbac/project_rbac_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package rbac
import (
"github.com/goharbor/harbor/src/common/models"
"github.com/goharbor/harbor/src/pkg/permission/types"
"github.com/goharbor/harbor/src/core/config"
)

type projectRBACUser struct {
Expand All @@ -32,6 +33,10 @@ func (user *projectRBACUser) GetUserName() string {

// GetPolicies returns policies of the visitor
func (user *projectRBACUser) GetPolicies() []*types.Policy {
cur := config.DisableAnonymous()
if cur {
return nil
}
if user.project.IsPublic() {
return getPoliciesForPublicProject(user.project.ProjectID)
}
Expand Down
7 changes: 4 additions & 3 deletions src/core/api/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ package api

import (
"fmt"
"strings"

pro "github.com/goharbor/harbor/src/common/dao/project"
"github.com/goharbor/harbor/src/common/security/local"
"strings"

"github.com/goharbor/harbor/src/common/dao"
"github.com/goharbor/harbor/src/common/models"
Expand Down Expand Up @@ -63,11 +64,11 @@ func (s *SearchAPI) Get() {
projects = result.Projects
} else {
cur := config.DisableAnonymous()
if !isAuthenticated && cur {
if !s.SecurityCtx.IsAuthenticated() && cur {
// return empty if anonymos access is disabled
return
}

projects, err = s.ProjectMgr.GetPublic()
if err != nil {
s.ParseAndHandleError("failed to get projects", err)
Expand Down

0 comments on commit 1d368e4

Please sign in to comment.