Skip to content

Commit 5b1b6c0

Browse files
committed
UPSTREAM: <carry>: Keep system:cluster:* groups
Signed-off-by: Nelo-T. Wallus <[email protected]>
1 parent ddbe171 commit 5b1b6c0

File tree

1 file changed

+16
-3
lines changed
  • pkg/registry/rbac/validation

1 file changed

+16
-3
lines changed

pkg/registry/rbac/validation/kcp.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,14 @@ func EffectiveUsers(clusterName logicalcluster.Name, u user.Info) []user.Info {
115115
Name: fmt.Sprintf("system:kcp:serviceaccount:%s:%s", clusters[0], nsNameSuffix),
116116
Extra: u.GetExtra(),
117117
}
118+
// Filter groups to only include system:authenticated
119+
// and system:cluster:*
118120
for _, g := range u.GetGroups() {
119121
if g == user.AllAuthenticated {
120-
rewritten.Groups = []string{user.AllAuthenticated}
121-
break
122+
rewritten.Groups = append(rewritten.Groups, user.AllAuthenticated)
123+
}
124+
if strings.HasPrefix(g, "system:cluster:") {
125+
rewritten.Groups = append(rewritten.Groups, g)
122126
}
123127
}
124128
ret = append(ret, rewritten)
@@ -147,7 +151,16 @@ func EffectiveUsers(clusterName logicalcluster.Name, u user.Info) []user.Info {
147151
recursive(u)
148152

149153
if wantAuthenticated {
150-
ret = append(ret, authenticated)
154+
authed := &user.DefaultInfo{
155+
Name: user.Anonymous,
156+
Groups: []string{user.AllAuthenticated},
157+
}
158+
for _, g := range u.GetGroups() {
159+
if strings.HasPrefix(g, "system:cluster:") {
160+
authed.Groups = append(authed.Groups, g)
161+
}
162+
}
163+
ret = append(ret, authed)
151164
}
152165
if wantUnauthenticated {
153166
ret = append(ret, unauthenticated)

0 commit comments

Comments
 (0)