-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Adding schema access rules to file based system access control #15886
Adding schema access rules to file based system access control #15886
Conversation
7c6a42c
to
160e98d
Compare
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. |
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.
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.
@@ -224,6 +227,10 @@ public void checkCanCreateSchema(Identity identity, AccessControlContext context | |||
if (!canAccessCatalog(identity, schema.getCatalogName(), ALL)) { | |||
denyCreateSchema(schema.toString()); | |||
} | |||
|
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.
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.
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.
Sure sounds good. I will place a catalog access check with the isSchemaOwner() method itself.
@@ -232,6 +239,10 @@ public void checkCanDropSchema(Identity identity, AccessControlContext context, | |||
if (!canAccessCatalog(identity, schema.getCatalogName(), ALL)) { | |||
denyDropSchema(schema.toString()); | |||
} | |||
|
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.
Same as above
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.
Noted
@@ -240,6 +251,10 @@ public void checkCanRenameSchema(Identity identity, AccessControlContext context | |||
if (!canAccessCatalog(identity, schema.getCatalogName(), ALL)) { | |||
denyRenameSchema(schema.toString(), newSchemaName); | |||
} | |||
|
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.
And here.
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.
Noted
@@ -385,4 +400,19 @@ public void checkCanRevokeTablePrivilege(Identity identity, AccessControlContext | |||
denyRevokeTablePrivilege(privilege.toString(), table.toString()); | |||
} | |||
} | |||
|
|||
private boolean isSchemaOwner(Identity identity, String schemaName) |
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.
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.
Noted
@@ -169,6 +169,73 @@ public void testSchemaOperations() | |||
})); | |||
} | |||
|
|||
@Test |
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.
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?
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.
@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.
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 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.
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.
@aweisberg I have made the required changes.
accessControlManager.checkCanCreateSchema(transactionId, admin, context, new CatalogSchemaName("some-catalog", "some-schema")); | ||
}); | ||
|
||
assertThrows(AccessDeniedException.class, () -> transaction(transactionManager, accessControlManager).execute(transactionId -> { |
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.
Why does one assertThrows have a bunch of different things in it? It will stop executing after the first one fails?
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.
Made the changes.
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.
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.
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.
Yes look like those got removed while making other changes in test, added them back.
b75a2c3
to
f345b1c
Compare
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.
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 <[email protected]>
f345b1c
to
94af7fc
Compare
@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. |
@arhimondr @rschlussel This is ready for review/merge. |
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 -