Skip to content

Commit 1c7b816

Browse files
authored
fix: Multiple choice option for namespace in Kubernetes resource permission (#5293)
* fix: multiple namespaces permission group * chore: rename namespaceObject to namespaceInArray to avoid misunderstanding two diff variables * chore: main merge
1 parent f0d6fee commit 1c7b816

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

cmd/external-app/wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/devtron-labs/devtron
22

33
go 1.21
44

5-
//toolchain go1.21.8
5+
toolchain go1.21.8
66

77
require (
88
github.com/Masterminds/semver v1.5.0

pkg/auth/user/UserCommonService.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,16 @@ func (impl UserCommonServiceImpl) CheckRbacForClusterEntity(cluster, namespace,
572572
resourceObj = "*"
573573
}
574574

575-
rbacResource := fmt.Sprintf("%s/%s/%s", strings.ToLower(cluster), strings.ToLower(namespaceObj), casbin.ResourceUser)
576575
resourcesArray := strings.Split(resourceObj, ",")
577-
for _, resourceVal := range resourcesArray {
578-
rbacObject := fmt.Sprintf("%s/%s/%s", groupObj, kindObj, resourceVal)
579-
allowed := managerAuth(rbacResource, token, rbacObject)
580-
if !allowed {
581-
return false
576+
namespacesArray := strings.Split(namespaceObj, ",")
577+
for _, namespaceInArray := range namespacesArray {
578+
rbacResource := fmt.Sprintf("%s/%s/%s", strings.ToLower(cluster), strings.ToLower(namespaceInArray), casbin.ResourceUser)
579+
for _, resourceVal := range resourcesArray {
580+
rbacObject := fmt.Sprintf("%s/%s/%s", groupObj, kindObj, resourceVal)
581+
allowed := managerAuth(rbacResource, token, rbacObject)
582+
if !allowed {
583+
return false
584+
}
582585
}
583586
}
584587
return true
@@ -690,8 +693,8 @@ func (impl UserCommonServiceImpl) GetUniqueKeyForAllEntity(role repository.RoleM
690693
key = fmt.Sprintf("%s_%s_%s_%s", role.Team, role.Action, role.AccessType, role.Entity)
691694
} else if len(role.Entity) > 0 {
692695
if role.Entity == bean.CLUSTER_ENTITIY {
693-
key = fmt.Sprintf("%s_%s_%s_%s_%s_%s", role.Entity, role.Action, role.Cluster,
694-
role.Namespace, role.Group, role.Kind)
696+
key = fmt.Sprintf("%s_%s_%s_%s_%s", role.Entity, role.Action, role.Cluster,
697+
role.Group, role.Kind)
695698
} else {
696699
key = fmt.Sprintf("%s_%s", role.Entity, role.Action)
697700
}

wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)