-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Ensure first table matched rule in access control #12204
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
lib/trino-plugin-toolkit/src/test/resources/file-based-system-access-table-mixed-groups.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| { | ||
| "tables": [ | ||
| { | ||
| "catalog": "some-catalog", | ||
| "schema": "my_schema", | ||
| "table": "my_table", | ||
| "privileges": ["SELECT", "GRANT_SELECT", "OWNERSHIP", "INSERT", "DELETE", "UPDATE"], | ||
| "group": "group1" | ||
| }, | ||
| { | ||
| "catalog": "some-catalog", | ||
| "schema": "my_schema", | ||
| "table": "my_table", | ||
| "columns" : [ | ||
| { | ||
| "name": "col_a", | ||
| "mask": "'mask_a'" | ||
| }, | ||
| { | ||
| "name": "col_b", | ||
| "mask": "'mask_b'" | ||
| } | ||
| ], | ||
| "privileges": ["SELECT", "GRANT_SELECT"], | ||
| "group": "group2" | ||
| }, | ||
| { | ||
| "catalog": "some-catalog", | ||
| "schema": "my_schema", | ||
| "table": "my_table", | ||
| "columns" : [ | ||
| { | ||
| "name": "col_a", | ||
| "mask": "'mask_a'" | ||
| }, | ||
| { | ||
| "name": "col_b", | ||
| "mask": "'mask_b'" | ||
| } | ||
| ], | ||
| "privileges": ["SELECT", "GRANT_SELECT"], | ||
| "filter": "country='US'", | ||
| "group": "group3" | ||
| } | ||
| ] | ||
| } |
43 changes: 43 additions & 0 deletions
43
lib/trino-plugin-toolkit/src/test/resources/table-mixed-groups.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| { | ||
| "tables": [ | ||
| { | ||
| "schema": "my_schema", | ||
| "table": "my_table", | ||
| "privileges": ["SELECT", "GRANT_SELECT", "OWNERSHIP", "INSERT", "DELETE", "UPDATE"], | ||
| "group": "group1" | ||
| }, | ||
| { | ||
| "schema": "my_schema", | ||
| "table": "my_table", | ||
| "columns" : [ | ||
| { | ||
| "name": "col_a", | ||
| "mask": "'mask_a'" | ||
| }, | ||
| { | ||
| "name": "col_b", | ||
| "mask": "'mask_b'" | ||
| } | ||
| ], | ||
| "privileges": ["SELECT", "GRANT_SELECT"], | ||
| "group": "group2" | ||
| }, | ||
| { | ||
| "schema": "my_schema", | ||
| "table": "my_table", | ||
| "columns" : [ | ||
| { | ||
| "name": "col_a", | ||
| "mask": "'mask_a'" | ||
| }, | ||
| { | ||
| "name": "col_b", | ||
| "mask": "'mask_b'" | ||
| } | ||
| ], | ||
| "privileges": ["SELECT", "GRANT_SELECT"], | ||
| "filter": "country='US'", | ||
| "group": "group3" | ||
| } | ||
| ] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting edge case. The user belongs to group1 and group3, but the table only has a filter for group3. I'm not quite sure what the correct semantics should be here.
For instance, the first entry may be about allowing users in group1 (e.g., employees in some department) to access a table, but the second entry might be about limiting what users in group3 can see (e.g., employees in some specific geography). In that case, it should use all filters that are present.
Let me think more about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that in all cases we should pick the first matching rule. This way we can control the way we want to limit access.
For example, in cases that we want to implement a more restrictive approach, we will place the table rules with filters and masks before the rules without them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally would lean towards returning all matching rules. But I'm not very familiar with file-based AC and its use cases so I'm not sure what's actually expected.
But doesn't it mean that if there is a second matching rule, it will never actually be returned and is entirely redundant?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe logic for returning all matching rules must take into account the rules without filters and maskings.
Rules order is important, so possible solution might be retrieving all matched filters / maskings rules until a rule without filter / masks is matched.
Anyway it's a subject for different PR