@@ -18,9 +18,12 @@ package rbac
18
18
19
19
import (
20
20
"errors"
21
+ "github.com/devtron-labs/common-lib/utils/k8s"
21
22
"github.com/devtron-labs/devtron/pkg/cluster"
22
23
"github.com/devtron-labs/devtron/pkg/cluster/environment"
24
+ "github.com/devtron-labs/devtron/pkg/k8s/application/bean"
23
25
"github.com/devtron-labs/devtron/util/rbac"
26
+ "k8s.io/apimachinery/pkg/runtime/schema"
24
27
"strings"
25
28
26
29
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
@@ -32,6 +35,7 @@ type ClusterRbacService interface {
32
35
CheckAuthorization (clusterName string , clusterId int , token string , userId int32 , rbacForClusterMappingsAlso bool ) (bool , error )
33
36
CheckAuthorisationForNode (token string , clusterName string , nodeName string , action string ) (authenticated bool )
34
37
CheckAuthorisationForNodeWithClusterId (token string , clusterId int , nodeName string , action string ) (authenticated bool , err error )
38
+ CheckAuthorisationForAllK8sPermissions (token string , clusterName string , action string ) bool
35
39
}
36
40
37
41
type ClusterRbacServiceImpl struct {
@@ -139,3 +143,12 @@ func (impl *ClusterRbacServiceImpl) FetchAllowedClusterMap(userId int32) (map[st
139
143
return allowedClustersMap , err
140
144
141
145
}
146
+
147
+ func (impl * ClusterRbacServiceImpl ) CheckAuthorisationForAllK8sPermissions (token string , clusterName string , action string ) (b2 bool ) {
148
+ resource , object := impl .enforcerUtil .GetRBACNameForClusterEntity (clusterName , k8s.ResourceIdentifier {
149
+ Name : bean .ALL ,
150
+ Namespace : bean .ALL ,
151
+ GroupVersionKind : schema.GroupVersionKind {Group : bean .ALL , Kind : bean .ALL },
152
+ })
153
+ return impl .enforcer .Enforce (token , strings .ToLower (resource ), action , object )
154
+ }
0 commit comments