Skip to content
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

RBAC V2 - Roles APIs #245

Merged
merged 3 commits into from
Apr 22, 2024
Merged

Conversation

bailinhe
Copy link
Contributor

continue work on #219

The API should be updated to use them in place of direct role assignments. The scope of this task is to make the following API changes:

  • update query engine to support v2 roles managements
  • add API endpoints to support v2 roles managements

Signed-off-by: Bailin He <[email protected]>
Copy link
Contributor

@jnschaeffer jnschaeffer left a comment

Choose a reason for hiding this comment

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

Nice first pass. Not all of these are requested changes.

internal/api/response.go Show resolved Hide resolved
internal/api/roles_v2.go Outdated Show resolved Hide resolved
internal/api/roles_v2.go Outdated Show resolved Hide resolved
internal/api/roles_v2.go Outdated Show resolved Hide resolved
internal/api/roles_v2.go Show resolved Hide resolved
internal/query/roles_v2.go Show resolved Hide resolved
internal/query/roles_v2.go Outdated Show resolved Hide resolved
internal/query/roles_v2.go Outdated Show resolved Hide resolved
internal/query/roles_v2.go Outdated Show resolved Hide resolved
internal/query/roles_v2_test.go Show resolved Hide resolved
Signed-off-by: Bailin He <[email protected]>
internal/api/roles_v2.go Show resolved Hide resolved
@@ -26,6 +26,22 @@ const (
GrantRelationship = "grant"
)

// RoleAction is the list of actions that can be performed on a role resource
type RoleAction string
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have an entire type for this?

Copy link
Contributor Author

@bailinhe bailinhe Apr 22, 2024

Choose a reason for hiding this comment

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

I think the actions should be an enum, same goes with RoleBindingActions

internal/iapl/rbac.go Show resolved Hide resolved
internal/query/errors.go Outdated Show resolved Hide resolved

defer span.End()

roleName = strings.TrimSpace(roleName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Right; I think that would be good.

internal/query/roles_v2.go Outdated Show resolved Hide resolved
internal/query/roles_v2.go Outdated Show resolved Hide resolved
internal/query/roles_v2.go Outdated Show resolved Hide resolved
internal/query/roles_v2.go Outdated Show resolved Hide resolved
Comment on lines +577 to +582
// there could be multiple subject types for a permission,
// e.g.
// infratographer/rolev2:lb_viewer#loadbalancer_get_rel@infratographer/user:*
// infratographer/rolev2:lb_viewer#loadbalancer_get_rel@infratographer/client:*
// here we only need one of them since the action is the only thing we care
// about
Copy link
Contributor

Choose a reason for hiding this comment

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

This will probably bite us. A better solution would probably be to have some singleton subject set definition that points to all subject types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree a more elegant solution is more desirable, but I think we can have a seperate PR to play with the IAPL

@bailinhe bailinhe force-pushed the rbac-v2-roles branch 2 times, most recently from 6f0d6c2 to 03ddab7 Compare April 22, 2024 18:30
Co-authored-by: John Schaeffer <[email protected]>
Signed-off-by: Bailin He <[email protected]>
@jnschaeffer jnschaeffer merged commit ca13cbc into infratographer:main Apr 22, 2024
4 checks passed
@bailinhe bailinhe mentioned this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants