Skip to content

Commit

Permalink
Authorize role endpoints as admin actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Dec 12, 2023
1 parent 3884f1f commit cbc73e1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/auth/auth_with_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3887,6 +3887,10 @@ func (a *ServerWithRoles) CreateRole(ctx context.Context, role types.Role) (type
return nil, trace.Wrap(err)
}

if err := authz.AuthorizeAdminAction(ctx, &a.context); err != nil {
return nil, trace.Wrap(err)
}

if err := a.validateRole(ctx, role); err != nil {
return nil, trace.Wrap(err)
}
Expand All @@ -3901,6 +3905,10 @@ func (a *ServerWithRoles) UpdateRole(ctx context.Context, role types.Role) (type
return nil, trace.Wrap(err)
}

if err := authz.AuthorizeAdminAction(ctx, &a.context); err != nil {
return nil, trace.Wrap(err)
}

if err := a.validateRole(ctx, role); err != nil {
return nil, trace.Wrap(err)
}
Expand All @@ -3915,6 +3923,10 @@ func (a *ServerWithRoles) UpsertRole(ctx context.Context, role types.Role) (type
return nil, trace.Wrap(err)
}

if err := authz.AuthorizeAdminAction(ctx, &a.context); err != nil {
return nil, trace.Wrap(err)
}

if err := a.validateRole(ctx, role); err != nil {
return nil, trace.Wrap(err)
}
Expand Down Expand Up @@ -4062,6 +4074,11 @@ func (a *ServerWithRoles) DeleteRole(ctx context.Context, name string) error {
if err := a.action(apidefaults.Namespace, types.KindRole, types.VerbDelete); err != nil {
return trace.Wrap(err)
}

if err := authz.AuthorizeAdminAction(ctx, &a.context); err != nil {
return trace.Wrap(err)
}

// DELETE IN (7.0)
// It's OK to delete this code alongside migrateOSS code in auth.
// It prevents 6.0 from migrating resources multiple times
Expand Down

0 comments on commit cbc73e1

Please sign in to comment.