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

[RFC][v3] Authorization Rules in V3 #10237

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

abhinav-hasura
Copy link
Member

Description

Rendered

@abhinav-hasura abhinav-hasura requested a review from a team as a code owner May 14, 2024 22:41
@abhinav-hasura abhinav-hasura added the k/rfc RFC for a new feature / process label May 14, 2024

Note, however, that cell-level authorization will not be supported by this system, since you define type (column) permissions and model (row) permissions independently.

3. **Are any changes required to the NDC protocol?**
Copy link
Contributor

Choose a reason for hiding this comment

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

But if row and column permissions are disjoint, would you not want to push down the cell-level predicates? Or are you proposing that we redact data on the engine side.

That would be simpler but result in more network overhead.

I think it'd be worth spelling this out here.

Comment on lines +277 to +282
```yaml
allowObjects:
relationship:
name: 'my_relationship'
relatedObjectAllowed: true
```
Copy link
Contributor

Choose a reason for hiding this comment

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

If this effectively autogenerates the permissions on the target model, what does it mean if one was to apply this attribute on the reverse relationship (ie the relationship from the target to the source)? Or if the target model already had permissions defined? It's unclear to me how this composes with everything else.

Comment on lines +127 to +150
authorizationRules:
# Rule 1: Allow users to see their own orders
- allowObjects:
fieldComparison:
fieldName: user_id
operator: _eq
value:
sessionVariable: x-hasura-user-id
condition:
equals:
left: sessionVariable: x-hasura-role
right: literal: user
# Rule 2: Disallow anyone except admins to see hidden orders
- denyObjects:
fieldComparison:
fieldName: is_hidden
operator: _eq
value:
literal: true
condition:
not:
equals:
left: sessionVariable: x-hasura-role
right: literal: admin
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope we're planning on writing an expression evaluation system that evaluates and simplifies these expressions before pushing them down to the connectors? Otherwise this is going to get ugly and we'll be spitting very complex where clauses into databases.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the idea is that (for now at least) expressions are evaluated in the engine only, since they only depend on the values of session variables. I agree that pushing down subexpressions is not a tractable plan.

Comment on lines +311 to +313
1. **Will existing metadata continue to be work?**

Yes, existing metadata (using the `v1` version of permissions objects) will continue to work and trivially maps to the new system where the condition is an equality check on the `x-hasura-role` session variable.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should consider letting the user pick which way they'd prefer to express their permissions, either this advanced system, or the existing role based system (which we just desugar into the the advanced system behind the scenes). This advanced system is very powerful, but also less obvious how to use it to recreate the simple use case and I contend that users who just need basic role-based permissions would find the old mechanism easier to author and understand.

To be clear, this doesn't mean just retaining support for the v1 ModelPermissions and TypePermissions, it means including both options on v2. Just retaining the old v1 types is not as good as it implicitly discourages their use because they are an "old version".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/rfc RFC for a new feature / process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants