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

role-binding v2 schema and IAPL #219

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

bailinhe
Copy link
Contributor

@bailinhe bailinhe commented Mar 5, 2024

In order to separate roles from bindings in permissions-api, we need to update the generated SpiceDB schema with a definition for bindings and permissions that check both direct assignment to roles and bindings (i.e., we don’t want to break existing assignments). The scope of this task is to update permissions-api to generate a SpiceDB schema with a binding definition that associates a subject (i.e., any principal) to a role.

see this doc for more

@bailinhe bailinhe marked this pull request as ready for review March 5, 2024 18:18
@bailinhe bailinhe requested review from a team as code owners March 5, 2024 18:18
@bailinhe bailinhe mentioned this pull request Mar 6, 2024
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.

Leaving a partial review here of the policy language stuff. Moving on to the rest.

internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Show resolved Hide resolved
internal/iapl/policy.go Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/rbac.go Outdated Show resolved Hide resolved
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.

More thoughts. Overall, the direction of this is good, but it looks like we're adding more customizability than may be warranted and the code could stand to be broken down into smaller, more easily consumed units than it currently is.

internal/iapl/rbac.go Outdated Show resolved Hide resolved
internal/iapl/rbac.go Outdated Show resolved Hide resolved
internal/query/relations.go Show resolved Hide resolved
@bailinhe bailinhe force-pushed the role-binding-schema branch 2 times, most recently from 27840bd to 41bcf2e Compare March 20, 2024 15:43
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.

More thoughts.

internal/iapl/rbac.go Outdated Show resolved Hide resolved
internal/iapl/rbac.go Outdated Show resolved Hide resolved
internal/iapl/rbac.go Outdated Show resolved Hide resolved
internal/query/relations.go Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
docs/rbac.md Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
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.

More thoughts.

internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Show resolved Hide resolved
internal/iapl/policy.go Outdated Show resolved Hide resolved
internal/iapl/policy.go Show resolved Hide resolved
internal/iapl/policy.go Show resolved Hide resolved
internal/iapl/policy.go Show resolved Hide resolved
Comment on lines +470 to +555
// Relationships like member_roles, available_roles, are created to support
// role inheritance, e.g., an org should be able to use roles defined by its
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs more explanation, I think, preferably in the Markdown doc.

internal/iapl/policy.go Show resolved Hide resolved
Comment on lines 13 to 15
// AvailableRoleRelation is the name of the relationship that list all roles
// that are available for a given resource
AvailableRoleRelation = "avail_role"
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it could be named a little better, since it's actually used as an action everywhere, not as a relation. Maybe this would be better? Not sure.

Suggested change
// AvailableRoleRelation is the name of the relationship that list all roles
// that are available for a given resource
AvailableRoleRelation = "avail_role"
// UseRoleAction is the name of the action that allows the use of a role
// for listing, binding, etc in the context of a given resource
UseRoleAction = "iam_use_role"

@bailinhe bailinhe force-pushed the role-binding-schema branch 3 times, most recently from 0dc1a3a to 8d474ee Compare April 4, 2024 19:24
*/
type RBAC struct {
// RoleResource is the name of the resource type that represents a role.
RoleResource RBACResourceDefinition
Copy link
Contributor

Choose a reason for hiding this comment

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

Is RBACResourceDefinition here so we can create the resource type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I changed that to be not private because I realized at some point we need to create a policy for tests

internal/spicedbx/schema.go Show resolved Hide resolved
jnschaeffer
jnschaeffer previously approved these changes Apr 4, 2024
Co-authored-by: John Schaeffer <[email protected]>
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.

Looks good enough to build on. Work on things like moving ConditionSets into conditions and fixing the generated Mermaid graph will come later.

@bailinhe bailinhe merged commit 9417171 into infratographer:main Apr 10, 2024
4 checks passed
@bailinhe bailinhe mentioned this pull request Apr 15, 2024
2 tasks
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