-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow all catalog access by default in file-based access control
If no catalog rules are defined, allow all catalog access
- Loading branch information
Showing
18 changed files
with
70 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"queries": [ | ||
{ | ||
"user": "admin", | ||
|
5 changes: 0 additions & 5 deletions
5
presto-docs/src/main/sphinx/security/system-information-access.json
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"system_information": [ | ||
{ | ||
"user": "admin", | ||
|
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"impersonation": [ | ||
{ | ||
"original_user": "alice", | ||
|
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"impersonation": [ | ||
{ | ||
"original_user": "alice", | ||
|
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"principals": [ | ||
{ | ||
"principal": "(.*)", | ||
|
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"system_information": [ | ||
{ | ||
"user": "admin", | ||
|
This file contains 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 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 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 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 |
---|---|---|
|
@@ -73,6 +73,7 @@ public class TestFileBasedSystemAccessControl | |
private static final SystemSecurityContext CHARLIE = new SystemSecurityContext(charlie, queryId); | ||
private static final SystemSecurityContext ALICE = new SystemSecurityContext(alice, queryId); | ||
private static final SystemSecurityContext JOE = new SystemSecurityContext(joe, queryId); | ||
private static final SystemSecurityContext UNKNOWN = new SystemSecurityContext(Identity.ofUser("some-unknown-user-id"), queryId); | ||
|
||
private static final String CREATE_SCHEMA_ACCESS_DENIED_MESSAGE = "Access Denied: Cannot create schema .*"; | ||
private static final String DROP_SCHEMA_ACCESS_DENIED_MESSAGE = "Access Denied: Cannot drop schema .*"; | ||
|
@@ -94,6 +95,45 @@ public class TestFileBasedSystemAccessControl | |
private static final String GRANT_DELETE_PRIVILEGE_ACCESS_DENIED_MESSAGE = "Access Denied: Cannot grant privilege DELETE on table .*"; | ||
private static final String REVOKE_DELETE_PRIVILEGE_ACCESS_DENIED_MESSAGE = "Access Denied: Cannot revoke privilege DELETE on table .*"; | ||
|
||
@Test | ||
public void testEmptyFile() | ||
{ | ||
SystemAccessControl accessControl = newFileBasedSystemAccessControl("empty.json"); | ||
|
||
accessControl.checkCanCreateSchema(UNKNOWN, new CatalogSchemaName("some-catalog", "unknown")); | ||
accessControl.checkCanDropSchema(UNKNOWN, new CatalogSchemaName("some-catalog", "unknown")); | ||
accessControl.checkCanRenameSchema(UNKNOWN, new CatalogSchemaName("some-catalog", "unknown"), "new_unknown"); | ||
accessControl.checkCanSetSchemaAuthorization(UNKNOWN, | ||
new CatalogSchemaName("some-catalog", "unknown"), | ||
new PrestoPrincipal(PrincipalType.ROLE, "some_role")); | ||
accessControl.checkCanShowCreateSchema(UNKNOWN, new CatalogSchemaName("some-catalog", "unknown")); | ||
|
||
accessControl.checkCanSelectFromColumns(UNKNOWN, new CatalogSchemaTableName("some-catalog", "unknown", "unknown"), ImmutableSet.of()); | ||
accessControl.checkCanShowColumns(UNKNOWN, new CatalogSchemaTableName("some-catalog", "unknown", "unknown")); | ||
accessControl.checkCanInsertIntoTable(UNKNOWN, new CatalogSchemaTableName("some-catalog", "unknown", "unknown")); | ||
accessControl.checkCanDeleteFromTable(UNKNOWN, new CatalogSchemaTableName("some-catalog", "unknown", "unknown")); | ||
|
||
accessControl.checkCanCreateTable(UNKNOWN, new CatalogSchemaTableName("some-catalog", "unknown", "unknown")); | ||
accessControl.checkCanDropTable(UNKNOWN, new CatalogSchemaTableName("some-catalog", "unknown", "unknown")); | ||
accessControl.checkCanRenameTable(UNKNOWN, | ||
new CatalogSchemaTableName("some-catalog", "unknown", "unknown"), | ||
new CatalogSchemaTableName("some-catalog", "unknown", "new_unknown")); | ||
|
||
accessControl.checkCanSetUser(Optional.empty(), "unknown"); | ||
accessControl.checkCanSetUser(Optional.of(new KerberosPrincipal("[email protected]")), "unknown"); | ||
|
||
accessControl.checkCanSetSystemSessionProperty(UNKNOWN, "anything"); | ||
accessControl.checkCanSetCatalogSessionProperty(UNKNOWN, "unknown", "anything"); | ||
|
||
accessControl.checkCanExecuteQuery(UNKNOWN); | ||
accessControl.checkCanViewQueryOwnedBy(UNKNOWN, "anyone"); | ||
accessControl.checkCanKillQueryOwnedBy(UNKNOWN, "anyone"); | ||
|
||
// system information access is denied by default | ||
assertThrows(AccessDeniedException.class, () -> accessControl.checkCanReadSystemInformation(UNKNOWN)); | ||
assertThrows(AccessDeniedException.class, () -> accessControl.checkCanWriteSystemInformation(UNKNOWN)); | ||
} | ||
|
||
@Test | ||
public void testSchemaRulesForCheckCanCreateSchema() | ||
{ | ||
|
5 changes: 0 additions & 5 deletions
5
presto-plugin-toolkit/src/test/resources/catalog_principal.json
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"principals": [ | ||
{ | ||
"principal": "(.*)", | ||
|
This file contains 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 @@ | ||
{} |
5 changes: 0 additions & 5 deletions
5
presto-plugin-toolkit/src/test/resources/file-based-system-access-schema.json
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"schemas": [ | ||
{ | ||
"catalog": "unknown", | ||
|
5 changes: 0 additions & 5 deletions
5
presto-plugin-toolkit/src/test/resources/file-based-system-access-table.json
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"tables": [ | ||
{ | ||
"catalog": "unknown", | ||
|
5 changes: 0 additions & 5 deletions
5
presto-plugin-toolkit/src/test/resources/file-based-system-no-access.json
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"schemas": [ | ||
], | ||
"tables": [ | ||
|
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"queries": [ | ||
{ | ||
"user": "admin", | ||
|
5 changes: 0 additions & 5 deletions
5
presto-plugin-toolkit/src/test/resources/system-information.json
This file contains 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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
{ | ||
"catalogs": [ | ||
{ | ||
"allow": true | ||
} | ||
], | ||
"system_information": [ | ||
{ | ||
"user": "admin", | ||
|