Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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/app/workflow/AppWorkflowRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ func (impl AppWorkflowRestHandlerImpl) FindAppWorkflow(w http.ResponseWriter, r
itr := 0
for _, val := range workflowIdToObjectMap {
rbacObjects = append(rbacObjects, val)
// doing this here as casbin returns lowercase objects which will not match in case of Project with uppercase letters, not done in enterprise as we use custom enforcer which returns the map with given expected rbac objects
workNameObjectMap[strings.ToLower(val)] = workflowsList[itr]
workNameObjectMap[val] = workflowsList[itr]
itr++
}

Expand Down
30 changes: 15 additions & 15 deletions util/rbac/EnforcerUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsByEnvIdsAndAppId(envIds []int, appId

for _, env := range envs {
if _, ok := objects[env.Id]; !ok {
objects[env.Id] = fmt.Sprintf("%s/%s", env.EnvironmentIdentifier, appName)
objects[env.Id] = strings.ToLower(fmt.Sprintf("%s/%s", env.EnvironmentIdentifier, appName))
envObjectToName[objects[env.Id]] = env.Name
}
}
Expand All @@ -144,7 +144,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsByAppIds(appIds []int) map[int]string
}
for _, item := range result {
if _, ok := objects[item.Id]; !ok {
objects[item.Id] = fmt.Sprintf("%s/%s", item.Team.Name, item.AppName)
objects[item.Id] = strings.ToLower(fmt.Sprintf("%s/%s", item.Team.Name, item.AppName))
}
}
return objects
Expand Down Expand Up @@ -174,7 +174,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsForAllApps(appType helper.AppType) ma
}
for _, item := range result {
if _, ok := objects[item.Id]; !ok {
objects[item.Id] = fmt.Sprintf("%s/%s", item.Team.Name, strings.ToLower(item.AppName))
objects[item.Id] = strings.ToLower(fmt.Sprintf("%s/%s", item.Team.Name, item.AppName))
}
}
return objects
Expand All @@ -188,7 +188,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsForAllAppsWithTeamID(teamID int, appT
}
for _, item := range result {
if _, ok := objects[item.Id]; !ok {
objects[item.Id] = fmt.Sprintf("%s/%s", item.Team.Name, strings.ToLower(item.AppName))
objects[item.Id] = strings.ToLower(fmt.Sprintf("%s/%s", item.Team.Name, strings.ToLower(item.AppName)))
}
}
return objects
Expand Down Expand Up @@ -433,8 +433,8 @@ func (impl EnforcerUtilImpl) GetHelmObjectByAppNameAndEnvId(appName string, envI
if !strings.HasPrefix(env.EnvironmentIdentifier, fmt.Sprintf("%s__", env.Cluster.ClusterName)) {
environmentIdentifier = fmt.Sprintf("%s__%s", env.Cluster.ClusterName, env.EnvironmentIdentifier)
}*/
return fmt.Sprintf("%s/%s/%s", application.Team.Name, environmentIdentifier, application.AppName),
fmt.Sprintf("%s/%s/%s", application.Team.Name, environmentIdentifier2, application.AppName)
return strings.ToLower(fmt.Sprintf("%s/%s/%s", application.Team.Name, environmentIdentifier, application.AppName)),
strings.ToLower(fmt.Sprintf("%s/%s/%s", application.Team.Name, environmentIdentifier2, application.AppName))
}

func (impl EnforcerUtilImpl) GetHelmObjectByProjectIdAndEnvId(teamId int, envId int) (string, string) {
Expand Down Expand Up @@ -517,7 +517,7 @@ func (impl EnforcerUtilImpl) GetAppObjectByCiPipelineIds(ciPipelineIds []int) ma
}
for _, pipeline := range models {
if _, ok := objects[pipeline.Id]; !ok {
appObject := fmt.Sprintf("%s/%s", pipeline.App.Team.Name, pipeline.App.AppName)
appObject := strings.ToLower(fmt.Sprintf("%s/%s", pipeline.App.Team.Name, pipeline.App.AppName))
objects[pipeline.Id] = appObject
}
}
Expand All @@ -533,8 +533,8 @@ func (impl EnforcerUtilImpl) GetAppAndEnvObjectByPipelineIds(cdPipelineIds []int
}
for _, pipeline := range models {
if _, ok := objects[pipeline.Id]; !ok {
appObject := fmt.Sprintf("%s/%s", pipeline.App.Team.Name, pipeline.App.AppName)
envObject := fmt.Sprintf("%s/%s", pipeline.Environment.EnvironmentIdentifier, pipeline.App.AppName)
appObject := strings.ToLower(fmt.Sprintf("%s/%s", pipeline.App.Team.Name, pipeline.App.AppName))
envObject := strings.ToLower(fmt.Sprintf("%s/%s", pipeline.Environment.EnvironmentIdentifier, pipeline.App.AppName))
objects[pipeline.Id] = []string{appObject, envObject}
}
}
Expand All @@ -549,7 +549,7 @@ func (impl EnforcerUtilImpl) GetRbacObjectsForAllAppsWithMatchingAppName(appName
}
for _, item := range result {
if _, ok := objects[item.Id]; !ok {
objects[item.Id] = fmt.Sprintf("%s/%s", item.Team.Name, strings.ToLower(item.AppName))
objects[item.Id] = strings.ToLower(fmt.Sprintf("%s/%s", item.Team.Name, item.AppName))
}
}
return objects
Expand All @@ -572,8 +572,8 @@ func (impl EnforcerUtilImpl) GetAppAndEnvObjectByPipeline(cdPipelines []*bean.CD
}
for _, pipeline := range cdPipelines {
if _, ok := objects[pipeline.Id]; !ok {
appObject := fmt.Sprintf("%s/%s", teamMap[pipeline.TeamId], pipeline.AppName)
envObject := fmt.Sprintf("%s/%s", pipeline.EnvironmentIdentifier, pipeline.AppName)
appObject := strings.ToLower(fmt.Sprintf("%s/%s", teamMap[pipeline.TeamId], pipeline.AppName))
envObject := strings.ToLower(fmt.Sprintf("%s/%s", pipeline.EnvironmentIdentifier, pipeline.AppName))
objects[pipeline.Id] = []string{appObject, envObject}
}
}
Expand All @@ -599,8 +599,8 @@ func (impl EnforcerUtilImpl) GetAppAndEnvObjectByDbPipeline(cdPipelines []*pipel
}
for _, pipeline := range cdPipelines {
if _, ok := objects[pipeline.Id]; !ok {
appObject := fmt.Sprintf("%s/%s", teamMap[pipeline.App.TeamId], pipeline.App.AppName)
envObject := fmt.Sprintf("%s/%s", pipeline.Environment.EnvironmentIdentifier, pipeline.App.AppName)
appObject := strings.ToLower(fmt.Sprintf("%s/%s", teamMap[pipeline.App.TeamId], pipeline.App.AppName))
envObject := strings.ToLower(fmt.Sprintf("%s/%s", pipeline.Environment.EnvironmentIdentifier, pipeline.App.AppName))
objects[pipeline.Id] = []string{appObject, envObject}
}
}
Expand Down Expand Up @@ -681,7 +681,7 @@ func (impl EnforcerUtilImpl) GetAllWorkflowRBACObjectsByAppId(appId int, workflo
teamName := application.Team.Name
objects := make(map[int]string, len(workflowNames))
for index, wfName := range workflowNames {
objects[workflowIds[index]] = fmt.Sprintf("%s/%s/%s", teamName, appName, wfName)
objects[workflowIds[index]] = strings.ToLower(fmt.Sprintf("%s/%s/%s", teamName, appName, wfName))
}
return objects
}
Expand Down