-
Notifications
You must be signed in to change notification settings - Fork 3k
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 FileBasedSystemAccessControl #3766
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/prestosql/cla. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/prestosql/cla. |
I think it was a deliberate choice to have table/schemas access control checked at catalog level with @haldes Why above mentioned solution does not work for you? |
Hi @kokosing, As I understand io.prestosql.plugin.base.security.FileBasedAccessControl is only available for hive connectors. We don't have similar access controls (schema, table) for other connectors. Please find below the slack discussion on the same |
Thanks. Are you going to cover access to tables and views as well? |
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.
So far so good. Some initial comments
...in-toolkit/src/main/java/io/prestosql/plugin/base/security/FileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
presto-plugin-toolkit/src/test/resources/file-based-system-access-schema.json
Show resolved
Hide resolved
...oolkit/src/test/java/io/prestosql/plugin/base/security/TestFileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
...oolkit/src/test/java/io/prestosql/plugin/base/security/TestFileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
@kokosing Thanks - Will work on it and get back. |
...in-toolkit/src/main/java/io/prestosql/plugin/base/security/FileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
...oolkit/src/test/java/io/prestosql/plugin/base/security/TestFileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
...oolkit/src/test/java/io/prestosql/plugin/base/security/TestFileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
...oolkit/src/test/java/io/prestosql/plugin/base/security/TestFileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
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.
% few minor comments
Thanks!
private static final SystemSecurityContext BOB = new SystemSecurityContext(bob, queryId); | ||
private static final SystemSecurityContext CHARLIE = new SystemSecurityContext(charlie, queryId); | ||
|
||
private static final String DROP_SCHEMA_ERR_MESSAGE = "Access Denied: Cannot drop schema"; |
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.
DROP_SCHEMA_ERR_MESSAGE -> DROP_SCHEMA_ACCESS_DENIED_MESSAGE
Same for all below.
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 changed.
private static final String RENAME_SCHEMA_ERR_MESSAGE = "Access Denied: Cannot rename schema from"; | ||
private static final String AUTH_SCHEMA_ERR_MESSAGE = "Access Denied: Cannot set authorization for schema"; | ||
private static final String SHOW_CREATE_SCHEMA_ERR_MESSAGE = "Access Denied: Cannot show create schema for"; | ||
private static final String INVALID_JSON_ERR_MESSAGE = "Invalid JSON file"; |
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.
INVALID_JSON_ERR_MESSAGE -> INVALID_JSON
@@ -268,4 +354,18 @@ private String getResourcePath(String resourceName) | |||
{ | |||
return this.getClass().getClassLoader().getResource(resourceName).getPath(); | |||
} | |||
|
|||
private static void assertDenied(ThrowingCallable callable, String expectedErrMessage) |
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.
assertDenied -> assertAccessDenied
expectedErrMessage -> expectedMessage
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 changed.
{ | ||
assertThatThrownBy(callable) | ||
.isInstanceOf(AccessDeniedException.class) | ||
.hasMessageStartingWith(expectedErrMessage); |
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.
check that message equals or matches the pattern
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.
@kokosing - I have changed to hasMessageMatching() and using pattern to match. Let me know if that's ok.
...oolkit/src/test/java/io/prestosql/plugin/base/security/TestFileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
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.
Please squash all commits and rebase.
Add schema access rules to FileBasedSystemAccessControl Add schema access rules to FileBasedSystemAccessControl Add schema access rules to FileBasedSystemAccessControl Add schema access rules to FileBasedSystemAccessControl Add schema access rules to FileBasedSystemAccessControl
@kokosing - I have squashed and did rebase. |
Automation hit: #2435 |
Merged, thanks! |
Cherry pick of trinodb/trino#3766 Co-authored-by: haldes <[email protected]>
Cherry pick of trinodb/trino#3766 Co-authored-by: haldes <[email protected]>
Currently FileBasedSystemAccessControl control has catalogRules, queryAccessRules, impersonationRules and principalUserMatchRules. The proposal here is to add schema access rules to it. This will give more granular access controls over the datasets.
At high level idea is to implement/enhance the below methods of FileBasedSystemAccessControl
Original Issue : #3733