Skip to content

[WIP] UPSTREAM: <carry>: Keep system:cluster:* groups #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: kcp-1.32.3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions pkg/registry/rbac/validation/kcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,14 @@ func EffectiveUsers(clusterName logicalcluster.Name, u user.Info) []user.Info {
Name: fmt.Sprintf("system:kcp:serviceaccount:%s:%s", clusters[0], nsNameSuffix),
Extra: u.GetExtra(),
}
// Filter groups to only include system:authenticated
// and system:cluster:*
for _, g := range u.GetGroups() {
if g == user.AllAuthenticated {
rewritten.Groups = []string{user.AllAuthenticated}
break
rewritten.Groups = append(rewritten.Groups, user.AllAuthenticated)
}
if strings.HasPrefix(g, "system:cluster:") {
rewritten.Groups = append(rewritten.Groups, g)
}
Comment on lines +118 to 126
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the globalsa if the feature flag is enabled. Maybe it'd make sense to keep all system: groups?

}
ret = append(ret, rewritten)
Expand Down Expand Up @@ -147,7 +151,16 @@ func EffectiveUsers(clusterName logicalcluster.Name, u user.Info) []user.Info {
recursive(u)

if wantAuthenticated {
ret = append(ret, authenticated)
authed := &user.DefaultInfo{
Name: user.Anonymous,
Groups: []string{user.AllAuthenticated},
}
for _, g := range u.GetGroups() {
if strings.HasPrefix(g, "system:cluster:") {
authed.Groups = append(authed.Groups, g)
}
}
ret = append(ret, authed)
}
if wantUnauthenticated {
ret = append(ret, unauthenticated)
Expand Down