Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit dd80be1

Browse files
authored
add: IRA Superadmin (#2212)
- Add SuperAdmin role as required e.g. by the cluster-agent - Remove scope validation for non cluster-scoped IRAs - Clear permissions denied if IRA feature is disabled
1 parent d95381a commit dd80be1

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

pkg/controller/permissions/permissions_check.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ func CheckPermissions(transport http.RoundTripper) router.HandlerFunc {
123123
denied, _ := v1.GrantsAll(app.Namespace, copyWithName(details.Permissions, imageName), authzPerms)
124124

125125
app.Status.Staged.ImagePermissionsDenied = denied
126+
} else {
127+
app.Status.Staged.ImagePermissionsDenied = nil
126128
}
127129

128130
// This is checking if the user granted all permissions that the app requires

pkg/install/install.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,10 @@ func Roles() ([]kclient.Object, error) {
744744
if err != nil {
745745
return nil, err
746746
}
747-
for _, role := range append(roles.ClusterRoles(), roles.AWSRoles()...) {
747+
r := roles.ClusterRoles()
748+
r = append(r, roles.SuperAdminRole())
749+
r = append(r, roles.AWSRoles()...)
750+
for _, role := range r {
748751
role := role
749752
objs = append(objs, &role)
750753
}

pkg/roles/roles.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const (
2222
GroupRoleAWSAcornIO = "role.aws.acorn.io"
2323

2424
AWSAdmin = "acorn:aws:admin"
25+
26+
// Cluster Agent Special
27+
SuperAdmin = "acorn:super-admin"
2528
)
2629

2730
var (
@@ -279,3 +282,20 @@ func AWSRoles() []rbacv1.ClusterRole {
279282
},
280283
}
281284
}
285+
286+
func SuperAdminRole() rbacv1.ClusterRole {
287+
return rbacv1.ClusterRole{
288+
ObjectMeta: metav1.ObjectMeta{
289+
Name: SuperAdmin,
290+
},
291+
Rules: []rbacv1.PolicyRule{
292+
{
293+
APIGroups: []string{"*"},
294+
Verbs: []string{"get", "list", "watch", "update", "patch", "delete", "deletecollection", "create"},
295+
Resources: []string{
296+
"*",
297+
},
298+
},
299+
},
300+
}
301+
}

pkg/server/registry/apigroups/admin/imageroleauthorizations/validator.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ func (s *Validator) Validate(ctx context.Context, obj runtime.Object) (result fi
1717
return append(result, field.Required(field.NewPath("imageSelector", "namePatterns"), "the image selector patterns must be defined to specify which images this rule applies to"))
1818
}
1919
result = append(result, validateSignatureRules(aiar.ImageSelector.Signatures)...)
20-
for _, scope := range aiar.Roles.Scopes {
21-
if scope == "cluster" {
22-
result = append(result, field.Invalid(field.NewPath("roles", "scopes"), scope, "cannot authorize cluster-scoped in ImageRoleAuthorizations - use ClusterImageRoleAuthorizations instead"))
23-
}
24-
// TODO(@iwilltry42): do we want to validate possible values here?
25-
}
2620
return
2721
}
2822

0 commit comments

Comments
 (0)