/
rbac.go
43 lines (41 loc) · 1.07 KB
/
rbac.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package dashboard
import (
"github.com/rancher/wrangler/pkg/apply"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func addUnauthenticatedRoles(apply apply.Apply) error {
return apply.
WithDynamicLookup().
WithSetID("cattle-unauthenticated").
ApplyObjects(
&rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: "cattle-unauthenticated",
},
Rules: []rbacv1.PolicyRule{
{
Verbs: []string{"get"},
APIGroups: []string{"management.cattle.io"},
Resources: []string{"settings"},
ResourceNames: []string{"first-login", "ui-pl", "ui-banners", "ui-brand", "ui-favicon"},
},
},
},
&rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: "cattle-unauthenticated",
},
Subjects: []rbacv1.Subject{{
Kind: "Group",
APIGroup: rbacv1.GroupName,
Name: "system:unauthenticated",
}},
RoleRef: rbacv1.RoleRef{
APIGroup: rbacv1.GroupName,
Kind: "ClusterRole",
Name: "cattle-unauthenticated",
},
},
)
}