-
Notifications
You must be signed in to change notification settings - Fork 83
Fleet RBAC - InheritedFleetWorkspacePermissions validation #348
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
Changes from all commits
f690386
2a1fd71
377cc01
d08ae0d
f10e67f
dbb090d
6ffd38c
2499660
1cfd47e
2cbaf6c
6a6b8de
91e6554
5d11abb
08254bb
44f5d22
70b603a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,9 +65,64 @@ func (g *GlobalRoleResolver) ClusterRulesFromRole(gr *v3.GlobalRole) ([]rbacv1.P | |
| } | ||
| rules = append(rules, templateRules...) | ||
| } | ||
|
|
||
| return rules, nil | ||
| } | ||
|
|
||
| // FleetWorkspacePermissionsResourceRulesFromRole finds rules which this GlobalRole gives on fleet resources in the workspace backing namespace. | ||
| // This is assuming a user has permissions in all workspaces (including fleet-local), which is not true. That's fine if we | ||
| // use it to evaluate InheritedFleetWorkspacePermissions.ResourceRules. However, it shouldn't be used in a more generic evaluation | ||
| // of permissions on the workspace backing namespace. | ||
| func (g *GlobalRoleResolver) FleetWorkspacePermissionsResourceRulesFromRole(gr *v3.GlobalRole) []rbacv1.PolicyRule { | ||
JonCrowther marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for _, name := range adminRoles { | ||
| if gr.Name == name { | ||
| return []rbacv1.PolicyRule{ | ||
| { | ||
| Verbs: []string{"*"}, | ||
| APIGroups: []string{"fleet.cattle.io"}, | ||
| Resources: []string{"clusterregistrationtokens", "gitreporestrictions", "clusterregistrations", "clusters", "gitrepos", "bundles", "clustergroups"}, | ||
| }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if gr == nil || gr.InheritedFleetWorkspacePermissions == nil { | ||
| return nil | ||
| } | ||
|
|
||
| return gr.InheritedFleetWorkspacePermissions.ResourceRules | ||
| } | ||
|
|
||
| // FleetWorkspacePermissionsWorkspaceVerbsFromRole finds rules which this GlobalRole gives on the fleetworkspace cluster-wide resources. | ||
| // This is assuming a user has permissions in all workspaces (including fleet-local), which is not true. That's fine if we | ||
| // use it to evaluate InheritedFleetWorkspacePermissions.WorkspaceVerbs. However, it shouldn't be used in a more generic evaluation | ||
| // of permissions on the workspace object. | ||
| func (g *GlobalRoleResolver) FleetWorkspacePermissionsWorkspaceVerbsFromRole(gr *v3.GlobalRole) []rbacv1.PolicyRule { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cluster rules contains a "Stint" that treats these users as having full permissions on these areas. I think you need something similar for this function as well - a "*" for the verbs should work ok.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what you mean here. Could you elaborate on this, please?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure - Here is the relevant logic. Basically, even though RestrictedAdmin has no permissions in these fields, we need to give the appropriate permissions so that RA can give this role to others. But the RA doesn't have/doesn't use this field, so you need special logic here to handle that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. see #348 (comment) |
||
| for _, name := range adminRoles { | ||
| if gr.Name == name { | ||
| return []rbacv1.PolicyRule{{ | ||
| Verbs: []string{"*"}, | ||
| APIGroups: []string{"management.cattle.io"}, | ||
| Resources: []string{"fleetworkspaces"}, | ||
| }} | ||
| } | ||
| } | ||
|
|
||
| if gr == nil || gr.InheritedFleetWorkspacePermissions == nil { | ||
| return nil | ||
| } | ||
|
|
||
| if gr.InheritedFleetWorkspacePermissions.WorkspaceVerbs != nil { | ||
| return []rbacv1.PolicyRule{{ | ||
MbolotSuse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Verbs: gr.InheritedFleetWorkspacePermissions.WorkspaceVerbs, | ||
| APIGroups: []string{"management.cattle.io"}, | ||
| Resources: []string{"fleetworkspaces"}, | ||
| }} | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // GetRoleTemplate allows the caller to retrieve the roleTemplates in use by a given global role. Does not | ||
| // recursively evaluate roleTemplates - only returns the top-level resources. | ||
| func (g *GlobalRoleResolver) GetRoleTemplatesForGlobalRole(gr *v3.GlobalRole) ([]*v3.RoleTemplate, error) { | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.