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

Ensure first table matched rule in access control #12204

Merged
merged 1 commit into from
May 9, 2022

Conversation

guyco33
Copy link
Member

@guyco33 guyco33 commented May 1, 2022

although it doesn't have masked columns or table filters

Description

Is this change a fix, improvement, new feature, refactoring, or other?

Fix regression for PR #11654

Is this a change to the core query engine, a connector, client library, or the SPI interfaces? (be specific)

How would you describe this change to a non-technical end user or system administrator?

Related issues, pull requests, and links

Fixes #12203

Documentation

(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.

Release notes

( ) No release notes entries required.
( ) Release notes entries required with the following suggested text:

# Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label May 1, 2022
@guyco33 guyco33 force-pushed the add_masking_tests branch from 8c219cf to 24322ce Compare May 1, 2022 18:58
@guyco33 guyco33 changed the title Pick the first matched access control table rule Pick the first match of access control table rule May 1, 2022
@guyco33 guyco33 force-pushed the add_masking_tests branch 3 times, most recently from 57f1f7f to 212bf47 Compare May 1, 2022 19:20
@guyco33 guyco33 changed the title Pick the first match of access control table rule Ensure first table matched rule in access control May 1, 2022
@guyco33 guyco33 force-pushed the add_masking_tests branch from 212bf47 to e8905e3 Compare May 1, 2022 21:45
Copy link
Member

@Praveen2112 Praveen2112 left a comment

Choose a reason for hiding this comment

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

I think we need it to be fixed for FileBasedAccessControl ? Can we have similar tests for them ?

@Praveen2112
Copy link
Member

@ksobolew Can you please take a look at this fix ?

Copy link
Contributor

@ksobolew ksobolew left a comment

Choose a reason for hiding this comment

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

Sorry, my bad. Streams of Optionals are tricky, and I was not really sure what the expected semantics are (initially I wanted to return all matching rules). The fix looks good, but as @Praveen2112 says, this should also be applied to connector-level FileBasedAccessControl.


assertEquals(
accessControl.getRowFilters(
userGroup1Group3,
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

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.

But doesn't it mean that if there is a second matching rule, it will never actually be returned and is entirely redundant?

Copy link
Member Author

@guyco33 guyco33 May 4, 2022

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

@guyco33 guyco33 force-pushed the add_masking_tests branch from e8905e3 to 484f3a4 Compare May 3, 2022 19:22
although it doesn't have masked columns or table filters
@guyco33 guyco33 force-pushed the add_masking_tests branch from 484f3a4 to 756f27d Compare May 4, 2022 06:20
@guyco33 guyco33 added the bug Something isn't working label May 4, 2022
Copy link
Contributor

@ksobolew ksobolew left a comment

Choose a reason for hiding this comment

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

Approving because it restores the behavior to the state from before #11654, though actual semantics are a matter of discussion.

@Praveen2112 Praveen2112 merged commit 0b2e428 into trinodb:master May 9, 2022
@Praveen2112
Copy link
Member

Merged !! Thanks for fixing this.

@github-actions github-actions bot added this to the 381 milestone May 9, 2022
@guyco33 guyco33 deleted the add_masking_tests branch May 9, 2022 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cla-signed
Development

Successfully merging this pull request may close these issues.

The masking logic has been broken since 376
4 participants