Skip to content

Commit 913fe9e

Browse files
authored
fix(rbac): update role bindings and permissions for user management (#6577)
1 parent 65ed4ca commit 913fe9e

File tree

3 files changed

+67
-47
lines changed

3 files changed

+67
-47
lines changed

controllers/user/main.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func main() {
6262
metricsAddr string
6363
enableLeaderElection bool
6464
probeAddr string
65-
configFilePath string
6665
rateLimiterOptions ratelimiter.RateLimiterOptions
6766
syncPeriod time.Duration
6867
minRequeueDuration time.Duration
@@ -125,12 +124,6 @@ func main() {
125124
time.Hour*2,
126125
"Sets the restrat predicate time duration for user controller restart. By default, the duration is set to 2 hours.",
127126
)
128-
flag.StringVar(
129-
&configFilePath,
130-
"config-file-path",
131-
"/config.yaml",
132-
"The path to the configuration file.",
133-
)
134127
flag.BoolVar(
135128
&secureMetrics,
136129
"metrics-secure",
@@ -243,9 +236,13 @@ func main() {
243236
setupLog.Error(err, "unable to create controller", "controller", "Operationrequest")
244237
os.Exit(1)
245238
}
246-
if err = (&userv1.Operationrequest{}).SetupWebhookWithManager(mgr); err != nil {
247-
setupLog.Error(err, "unable to create webhook", "webhook", "Operationrequest")
248-
os.Exit(1)
239+
if os.Getenv("DISABLE_WEBHOOKS") == "true" {
240+
setupLog.Info("disable all webhooks")
241+
} else {
242+
if err = (&userv1.Operationrequest{}).SetupWebhookWithManager(mgr); err != nil {
243+
setupLog.Error(err, "unable to create webhook", "webhook", "Operationrequest")
244+
os.Exit(1)
245+
}
249246
}
250247
if err = (&controllers.DeleteRequestReconciler{
251248
Client: mgr.GetClient(),

frontend/desktop/deploy/manifests/rbac.yaml

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,70 @@ kind: ClusterRole
33
metadata:
44
name: auth-system-manager-role
55
rules:
6-
- apiGroups: ["user.sealos.io"]
7-
resources: ["users"]
8-
verbs: ["list", "get", "create", "update", "patch", "watch"]
9-
- apiGroups: ["user.sealos.io"]
10-
resources: ["users/status"]
11-
verbs: ["list", "get", "create", "update", "patch", "watch"]
12-
- apiGroups: ["user.sealos.io"]
13-
resources: ["operationrequests", "deleterequests"]
14-
verbs: ["create", "get"]
6+
- apiGroups:
7+
- user.sealos.io
8+
resources:
9+
- users
10+
verbs:
11+
- create
12+
- delete
13+
- get
14+
- list
15+
- patch
16+
- update
17+
- watch
18+
- apiGroups:
19+
- user.sealos.io
20+
resources:
21+
- users/status
22+
verbs:
23+
- get
24+
- apiGroups:
25+
- user.sealos.io
26+
resources:
27+
- operationrequests
28+
verbs:
29+
- create
30+
- delete
31+
- get
32+
- list
33+
- patch
34+
- update
35+
- watch
36+
- apiGroups:
37+
- user.sealos.io
38+
resources:
39+
- operationrequests/status
40+
verbs:
41+
- get
42+
- apiGroups:
43+
- user.sealos.io
44+
resources:
45+
- deleterequests
46+
verbs:
47+
- create
48+
- delete
49+
- get
50+
- list
51+
- patch
52+
- update
53+
- watch
54+
- apiGroups:
55+
- user.sealos.io
56+
resources:
57+
- deleterequests/status
58+
verbs:
59+
- get
1560

1661
---
1762
apiVersion: rbac.authorization.k8s.io/v1
1863
kind: ClusterRoleBinding
1964
metadata:
20-
name: desktop-user-editor-role-binding
21-
roleRef:
22-
apiGroup: rbac.authorization.k8s.io
23-
kind: ClusterRole
24-
name: user-editor-role
25-
subjects:
26-
- kind: ServiceAccount
27-
name: desktop-frontend
28-
namespace: sealos
29-
---
30-
apiVersion: rbac.authorization.k8s.io/v1
31-
kind: ClusterRoleBinding
32-
metadata:
33-
name: desktop-operationrequest-editor-role-binding
65+
name: desktop-user-role-binding
3466
roleRef:
3567
apiGroup: rbac.authorization.k8s.io
3668
kind: ClusterRole
37-
name: operationrequest-editor-role
38-
subjects:
39-
- kind: ServiceAccount
40-
name: desktop-frontend
41-
namespace: sealos
42-
---
43-
apiVersion: rbac.authorization.k8s.io/v1
44-
kind: ClusterRoleBinding
45-
metadata:
46-
name: desktop-deleterequest-editor-role-binding
47-
roleRef:
48-
apiGroup: rbac.authorization.k8s.io
49-
kind: ClusterRole
50-
name: deleterequest-editor-role
69+
name: auth-system-manager-role
5170
subjects:
5271
- kind: ServiceAccount
5372
name: desktop-frontend

frontend/desktop/deploy/scripts/init.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22
set -e
3+
kubectl delete clusterrolebinding desktop-deleterequest-editor-role-binding --ignore-not-found=true
4+
kubectl delete clusterrolebinding desktop-operationrequest-editor-role-binding --ignore-not-found=true
5+
kubectl delete clusterrolebinding desktop-user-editor-role-binding --ignore-not-found=true
6+
37
kubectl apply -f manifests/deploy.yaml -f manifests/rbac.yaml -f manifests/ingress.yaml
48
cm_exists=$(kubectl get cm desktop-frontend-config -n sealos --ignore-not-found=true)
59
if [[ -n "$cm_exists" ]]; then

0 commit comments

Comments
 (0)