Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/restHandler/AppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package restHandler

import (
"encoding/json"
"fmt"
client "github.com/devtron-labs/devtron/api/helm-app"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/pkg/app"
Expand Down Expand Up @@ -330,7 +329,7 @@ func (handler AppRestHandlerImpl) GetAppListByTeamIds(w http.ResponseWriter, r *
accessedApps = append(accessedApps, app)
continue
}
object := fmt.Sprintf("%s/%s", project.ProjectName, app.Name)
object := handler.enforcerUtil.GetAppRBACNameByAppAndProjectName(project.ProjectName, app.Name)
if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, object); ok {
accessedApps = append(accessedApps, app)
}
Expand Down
5 changes: 5 additions & 0 deletions util/rbac/EnforcerUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type EnforcerUtil interface {
GetRbacObjectsByAppIds(appIds []int) map[int]string
GetAllActiveTeamNames() ([]string, error)
GetRbacObjectsByEnvIdsAndAppId(envIds []int, appId int) (map[int]string, map[string]string)
GetAppRBACNameByAppAndProjectName(projectName, appName string) string
}

type EnforcerUtilImpl struct {
Expand Down Expand Up @@ -604,3 +605,7 @@ func (impl EnforcerUtilImpl) GetAllActiveTeamNames() ([]string, error) {
}
return teamNames, nil
}

func (impl EnforcerUtilImpl) GetAppRBACNameByAppAndProjectName(projectName, appName string) string {
return fmt.Sprintf("%s/%s", strings.ToLower(projectName), strings.ToLower(appName))
}