Skip to content

Clarify how arrows operate over subject relations #219

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

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

josephschorr
Copy link
Member

No description provided.

@josephschorr josephschorr requested a review from jzelinskie April 23, 2024 18:55
Copy link

vercel bot commented Apr 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 23, 2024 7:25pm

@@ -38,8 +38,9 @@ definition someobjecttype {}
```

<Callout type="info">
Note that the examples are unprefixed.
You'll need to add the prefix from your permissions system if calling `WriteSchema` for a permissions system hosted in Serverless.
Note that the examples are unprefixed. You'll need to add the prefix from your
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we fix this in a followup when we add the linter?

@@ -105,7 +107,8 @@ definition group {
```

<Callout type="info">
Subject Relations are useful in RBAC-style permissions systems to grant "roles" to _sets_ of subjects, such as the members of a team.
Subject Relations are useful in RBAC-style permissions systems to grant
"roles" to _sets_ of subjects, such as the members of a team.
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this

Be **very careful** with wildcard support in your schema!
**Only** grant it to read permissions, unless you intend to allow for universal writing.
Be **very careful** with wildcard support in your schema! **Only** grant it to
read permissions, unless you intend to allow for universal writing.
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this

of relations. This allows for easy nested computation, and is more readable.
It is _recommended_ that the right side of all arrows refer to
**permissions**, instead of relations, as this allows for easy nested
computation, and is more readable.
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this

<Callout type="warning">
Arrows operate on the **object** of the subject(s) found on a `relation`. They
*do not* operate on the relation/permission of a subject, *even if the subject
refers to a relation or permission*.
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this

`parent->something` refers to the `something` permission on the **group**, and `#member` will be ignored for the arrow.

It is recommended to not use arrows over relations that allow for subject relations without noting that
fact via a comment.
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this

Why is this the case? In one word: **performance**. If arrows operated over
the subject's relation or permission, a full LookupSubjects call would be
necessary for the arrow to correctly "walk", which would make these
CheckPermission requests potentially *incredibly* expensive.
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this

You'll note that we also used `member` above in the relation example. Defining
`member` as a **permission** might be found when you have multiple "ways" a
subject can be a member of a resource, thus changing it from a simple relation
to a _computed_ set of subjects.
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this

</Callout>

## Comments

### Documentation Comments

<Callout type="info">
It is **highly** recommended to put doc comments on all definitions, relations and permissions.
It is **highly** recommended to put doc comments on all definitions, relations
and permissions.
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this


<Callout type="info">
Note that since `parent->read` calls the same `read` permission, it will form a recursive lookup across the chain of parent folder(s).
Note that since `parent->read` calls the same `read` permission, it will form
a recursive lookup across the chain of parent folder(s).
Copy link
Member

Choose a reason for hiding this comment

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

one sentence per line, need a linter for this

@josephschorr josephschorr merged commit fa4dd8d into main Apr 23, 2024
9 checks passed
@josephschorr josephschorr deleted the arrow-subject-rel branch April 23, 2024 21:23
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants