Skip to content

Adding schema access rules to file based system access control#15886

Merged
rschlussel merged 1 commit intoprestodb:masterfrom
agrawalreetika:filebased-schemaRules
Apr 28, 2021
Merged

Adding schema access rules to file based system access control#15886
rschlussel merged 1 commit intoprestodb:masterfrom
agrawalreetika:filebased-schemaRules

Conversation

@agrawalreetika
Copy link
Member

@agrawalreetika agrawalreetika commented Mar 30, 2021

Currently, file-based system access control allows defining catalog level rule. As a part of these changes, schema access rules can be included with file-based system access control for the below operations -

  • checkCanCreateSchema : If the user has access to the catalog and is also schema owner, then access is provided.
  • checkCanDropSchema : If the user has access to the catalog and is also schema owner, then access is provided.
  • checkCanRenameSchema : If the user has access to the catalog and is also schema owner, then access is provided.
== RELEASE NOTES ==

Security Changes

- Add ability to set schema access rules in file-based system access control

@agrawalreetika agrawalreetika force-pushed the filebased-schemaRules branch from 7c6a42c to 160e98d Compare March 30, 2021 04:44
@agrawalreetika agrawalreetika self-assigned this Mar 30, 2021
@aweisberg aweisberg self-requested a review April 9, 2021 17:11
@aweisberg
Copy link
Contributor

Can you link to the PR? It's a better source of context then the commit trinodb/trino#3766 Also the linked commit is not actually on Trino master.

Copy link
Contributor

@aweisberg aweisberg left a comment

Choose a reason for hiding this comment

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

Thanks!

Some simplification we can take from Trino and the tests seem to be a bit different and incomplete compared to what Trino is currently doing.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you ignore the linked diff and look at just how Trino is operating today they dropped the canAccessCatalog check here and pushed it into isSchemaOwner() which is simpler.

trinodb/trino#5039

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure sounds good. I will place a catalog access check with the isSchemaOwner() method itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted

Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted

Copy link
Contributor

Choose a reason for hiding this comment

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

We seem to deviate a lot on the tests? Are there "extra" tests that we don't need to cover? Can we do a better job of synchronizing?

Copy link
Member Author

Choose a reason for hiding this comment

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

@aweisberg I have tried covering all positive and negative tests for all the 3 schema operations. If you think something is missing here, I can add more tests to this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see why we deviated in several ways like not supporting groups and thus not needing to test groups.

If you fix the assertThrows I think it will be fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

@aweisberg I have made the required changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does one assertThrows have a bunch of different things in it? It will stop executing after the first one fails?

Copy link
Member Author

Choose a reason for hiding this comment

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

Made the changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are three cases now where there were five previously? It looks like it isn't validating whether the catalog can be accessed since coverage shows no cases where it is denied because the user can't access the catalog.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes look like those got removed while making other changes in test, added them back.

@agrawalreetika agrawalreetika force-pushed the filebased-schemaRules branch 3 times, most recently from b75a2c3 to f345b1c Compare April 14, 2021 03:21
Copy link
Contributor

@aweisberg aweisberg left a comment

Choose a reason for hiding this comment

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

It's still not testing the catalog ownership check. You can see because if you step through in the debugger it will never stop at return false in the test cases for schema. It does happen to do it in the read only catalog case, but I don't want to depend on testing unrelated functionality to cover it.

Sorry I know I am being picky here.

Cherry pick of trinodb/trino#3766

Co-authored-by: haldes <sumit.halder@gmail.com>
@agrawalreetika agrawalreetika force-pushed the filebased-schemaRules branch from f345b1c to 94af7fc Compare April 15, 2021 18:45
@agrawalreetika
Copy link
Member Author

@aweisberg I had added tests for catalog ownership check via read-only catalog access as you mentioned. In all the other cases AccessManager would redirect checks for Accesscatalog to checkCanAccessCatalog. Please review and let me know if any other changes are required.

@aweisberg
Copy link
Contributor

@arhimondr @rschlussel This is ready for review/merge.

@rschlussel rschlussel merged commit ea8e5f4 into prestodb:master Apr 28, 2021
@agrawalreetika agrawalreetika deleted the filebased-schemaRules branch April 28, 2021 15:52
@bhhari bhhari mentioned this pull request May 11, 2021
5 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.

3 participants