Package io.trino.testing
Class TestingAccessControlManager
java.lang.Object
io.trino.security.AccessControlManager
io.trino.testing.TestingAccessControlManager
- All Implemented Interfaces:
AccessControl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enum -
Constructor Summary
ConstructorsConstructorDescriptionTestingAccessControlManager(TransactionManager transactionManager, EventListenerManager eventListenerManager) TestingAccessControlManager(TransactionManager transactionManager, EventListenerManager eventListenerManager, AccessControlConfig accessControlConfig, io.opentelemetry.api.OpenTelemetry openTelemetry) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCreateViewWithExecuteFunction(SecurityContext context, QualifiedObjectName functionName) Is the identity allowed to create a view that executes the specified function?booleancanExecuteFunction(SecurityContext context, QualifiedObjectName functionName) Is the identity allowed to execute function?voidcheckCanAddColumns(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to add columns to the specified table.voidcheckCanAlterColumn(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to alter columns to the specified table.voidcheckCanCreateMaterializedView(SecurityContext context, QualifiedObjectName materializedViewName, Map<String, Object> properties) Check if identity is allowed to create the specified materialized view.voidcheckCanCreateSchema(SecurityContext context, CatalogSchemaName schemaName, Map<String, Object> properties) Check if identity is allowed to create the specified schema.voidcheckCanCreateTable(SecurityContext context, QualifiedObjectName tableName, Map<String, Object> properties) Check if identity is allowed to create the specified table with properties.voidcheckCanCreateView(SecurityContext context, QualifiedObjectName viewName) Check if identity is allowed to create the specified view.voidcheckCanCreateViewWithSelectFromColumns(SecurityContext context, QualifiedObjectName tableName, Set<String> columnNames) Check if identity is allowed to create a view that selects from the specified columns.voidcheckCanDeleteFromTable(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to delete from the specified table.voidcheckCanDropColumn(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to drop columns from the specified table.voidcheckCanDropMaterializedView(SecurityContext context, QualifiedObjectName materializedViewName) Check if identity is allowed to drop the specified materialized view.voidcheckCanDropSchema(SecurityContext context, CatalogSchemaName schemaName) Check if identity is allowed to drop the specified schema.voidcheckCanDropTable(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to drop the specified table.voidcheckCanDropView(SecurityContext context, QualifiedObjectName viewName) Check if identity is allowed to drop the specified view.voidcheckCanExecuteQuery(Identity identity) Checks if identity can execute a query.voidcheckCanExecuteTableProcedure(SecurityContext context, QualifiedObjectName table, String procedure) Check if identity is allowed to execute given table procedure on given tablevoidcheckCanImpersonateUser(Identity identity, String userName) Check if the identity is allowed impersonate the specified user.voidcheckCanInsertIntoTable(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to insert into the specified table.voidcheckCanKillQueryOwnedBy(Identity identity, Identity queryOwner) Checks if identity can kill a query owned by the specified user.voidcheckCanRefreshMaterializedView(SecurityContext context, QualifiedObjectName materializedViewName) Check if identity is allowed to refresh the specified materialized view.voidcheckCanRenameColumn(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to rename a column in the specified table.voidcheckCanRenameMaterializedView(SecurityContext context, QualifiedObjectName viewName, QualifiedObjectName newViewName) Check if identity is allowed to rename the specified materialized view.voidcheckCanRenameSchema(SecurityContext context, CatalogSchemaName schemaName, String newSchemaName) Check if identity is allowed to rename the specified schema.voidcheckCanRenameTable(SecurityContext context, QualifiedObjectName tableName, QualifiedObjectName newTableName) Check if identity is allowed to rename the specified table.voidcheckCanRenameView(SecurityContext context, QualifiedObjectName viewName, QualifiedObjectName newViewName) Check if identity is allowed to rename the specified view.voidcheckCanSelectFromColumns(SecurityContext context, QualifiedObjectName tableName, Set<String> columns) Check if identity is allowed to select from the specified columns.voidcheckCanSetCatalogSessionProperty(SecurityContext context, String catalogName, String propertyName) Check if identity is allowed to set the specified catalog property.voidcheckCanSetColumnComment(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to comment the specified column.voidcheckCanSetMaterializedViewProperties(SecurityContext context, QualifiedObjectName materializedViewName, Map<String, Optional<Object>> properties) Check if identity is allowed to set the properties of the specified materialized view.voidcheckCanSetSystemSessionProperty(Identity identity, String propertyName) Check if identity is allowed to set the specified system property.voidcheckCanSetTableComment(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to comment the specified table.voidcheckCanSetTableProperties(SecurityContext context, QualifiedObjectName tableName, Map<String, Optional<Object>> properties) Check if identity is allowed to set properties to the specified table.voidcheckCanSetUser(Optional<Principal> principal, String userName) Deprecated.voidcheckCanSetViewComment(SecurityContext context, QualifiedObjectName viewName) Check if identity is allowed to comment the specified view.voidcheckCanShowColumns(SecurityContext context, CatalogSchemaTableName table) Check if identity is allowed to show columns of tables by executing SHOW COLUMNS, DESCRIBE etc.voidcheckCanShowCreateTable(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to execute SHOW CREATE TABLE, SHOW CREATE VIEW or SHOW CREATE MATERIALIZED VIEWvoidcheckCanTruncateTable(SecurityContext context, QualifiedObjectName tableName) Check if identity is allowed to truncate the specified table.voidcheckCanUpdateTableColumns(SecurityContext context, QualifiedObjectName tableName, Set<String> updatedColumnNames) Check if identity is allowed to update the specified table.voidcheckCanViewQueryOwnedBy(Identity identity, Identity queryOwner) Checks if identity can view a query owned by the specified user.voidcolumnMask(QualifiedObjectName table, String column, String identity, ViewExpression mask) voiddeny(TestingAccessControlManager.TestingPrivilege... deniedPrivileges) voiddenyCatalogs(Predicate<String> deniedCatalogs) voiddenyIdentityTable(BiPredicate<Identity, String> denyIdentityTable) voiddenySchemas(Predicate<String> deniedSchemas) voiddenyTables(Predicate<SchemaTableName> deniedTables) filterCatalogs(SecurityContext securityContext, Set<String> catalogs) Filter the list of catalogs to those visible to the identity.filterColumns(SecurityContext context, String catalogName, Map<SchemaTableName, Set<String>> tableColumns) Filter lists of columns of multiple tables to those visible to the identity.filterQueriesOwnedBy(Identity identity, Collection<Identity> owners) Filter the list of users to those the identity view query owned by the user.filterSchemas(SecurityContext securityContext, String catalogName, Set<String> schemaNames) Filter the list of schemas in a catalog to those visible to the identity.filterTables(SecurityContext context, String catalogName, Set<SchemaTableName> tableNames) Filter the list of tables, materialized views and views to those visible to the identity.getColumnMask(SecurityContext context, QualifiedObjectName tableName, String column, Type type) getRowFilters(SecurityContext context, QualifiedObjectName tableName) privilege(String entityName, TestingAccessControlManager.TestingPrivilegeType type) privilege(String actorName, String entityName, TestingAccessControlManager.TestingPrivilegeType type) voidreset()voidrowFilter(QualifiedObjectName table, String identity, ViewExpression filter) Methods inherited from class io.trino.security.AccessControlManager
addSystemAccessControlFactory, checkCanCreateCatalog, checkCanCreateFunction, checkCanCreateRole, checkCanDenyEntityPrivilege, checkCanDenySchemaPrivilege, checkCanDenyTablePrivilege, checkCanDropCatalog, checkCanDropFunction, checkCanDropRole, checkCanExecuteProcedure, checkCanGrantEntityPrivilege, checkCanGrantRoles, checkCanGrantSchemaPrivilege, checkCanGrantTablePrivilege, checkCanReadSystemInformation, checkCanRevokeEntityPrivilege, checkCanRevokeRoles, checkCanRevokeSchemaPrivilege, checkCanRevokeTablePrivilege, checkCanSetCatalogRole, checkCanSetSchemaAuthorization, checkCanSetTableAuthorization, checkCanSetViewAuthorization, checkCanShowCreateSchema, checkCanShowCurrentRoles, checkCanShowFunctions, checkCanShowRoleGrants, checkCanShowRoles, checkCanShowSchemas, checkCanShowTables, checkCanWriteSystemInformation, destroy, filterFunctions, getAuthorizationFail, getAuthorizationSuccess, loadSystemAccessControl, loadSystemAccessControl, setConnectorAccessControlProvider, setSystemAccessControls
-
Constructor Details
-
TestingAccessControlManager
@Inject public TestingAccessControlManager(TransactionManager transactionManager, EventListenerManager eventListenerManager, AccessControlConfig accessControlConfig, io.opentelemetry.api.OpenTelemetry openTelemetry) -
TestingAccessControlManager
public TestingAccessControlManager(TransactionManager transactionManager, EventListenerManager eventListenerManager)
-
-
Method Details
-
privilege
public static TestingAccessControlManager.TestingPrivilege privilege(String entityName, TestingAccessControlManager.TestingPrivilegeType type) -
privilege
public static TestingAccessControlManager.TestingPrivilege privilege(String actorName, String entityName, TestingAccessControlManager.TestingPrivilegeType type) -
deny
-
rowFilter
-
columnMask
public void columnMask(QualifiedObjectName table, String column, String identity, ViewExpression mask) -
reset
public void reset() -
denyCatalogs
-
denySchemas
-
denyTables
-
denyIdentityTable
-
filterCatalogs
Description copied from interface:AccessControlFilter the list of catalogs to those visible to the identity.- Specified by:
filterCatalogsin interfaceAccessControl- Overrides:
filterCatalogsin classAccessControlManager
-
filterSchemas
public Set<String> filterSchemas(SecurityContext securityContext, String catalogName, Set<String> schemaNames) Description copied from interface:AccessControlFilter the list of schemas in a catalog to those visible to the identity.- Specified by:
filterSchemasin interfaceAccessControl- Overrides:
filterSchemasin classAccessControlManager
-
filterTables
public Set<SchemaTableName> filterTables(SecurityContext context, String catalogName, Set<SchemaTableName> tableNames) Description copied from interface:AccessControlFilter the list of tables, materialized views and views to those visible to the identity.- Specified by:
filterTablesin interfaceAccessControl- Overrides:
filterTablesin classAccessControlManager
-
checkCanImpersonateUser
Description copied from interface:AccessControlCheck if the identity is allowed impersonate the specified user.- Specified by:
checkCanImpersonateUserin interfaceAccessControl- Overrides:
checkCanImpersonateUserin classAccessControlManager
-
checkCanSetUser
Deprecated.Description copied from interface:AccessControlCheck if the principal is allowed to be the specified user.- Specified by:
checkCanSetUserin interfaceAccessControl- Overrides:
checkCanSetUserin classAccessControlManager
-
checkCanExecuteQuery
Description copied from interface:AccessControlChecks if identity can execute a query.- Specified by:
checkCanExecuteQueryin interfaceAccessControl- Overrides:
checkCanExecuteQueryin classAccessControlManager
-
checkCanViewQueryOwnedBy
Description copied from interface:AccessControlChecks if identity can view a query owned by the specified user. The method will not be called when the current user is the query owner.- Specified by:
checkCanViewQueryOwnedByin interfaceAccessControl- Overrides:
checkCanViewQueryOwnedByin classAccessControlManager
-
filterQueriesOwnedBy
Description copied from interface:AccessControlFilter the list of users to those the identity view query owned by the user. The method will not be called with the current user in the set.- Specified by:
filterQueriesOwnedByin interfaceAccessControl- Overrides:
filterQueriesOwnedByin classAccessControlManager
-
checkCanKillQueryOwnedBy
Description copied from interface:AccessControlChecks if identity can kill a query owned by the specified user. The method will not be called when the current user is the query owner.- Specified by:
checkCanKillQueryOwnedByin interfaceAccessControl- Overrides:
checkCanKillQueryOwnedByin classAccessControlManager
-
checkCanCreateSchema
public void checkCanCreateSchema(SecurityContext context, CatalogSchemaName schemaName, Map<String, Object> properties) Description copied from interface:AccessControlCheck if identity is allowed to create the specified schema.- Specified by:
checkCanCreateSchemain interfaceAccessControl- Overrides:
checkCanCreateSchemain classAccessControlManager
-
checkCanDropSchema
Description copied from interface:AccessControlCheck if identity is allowed to drop the specified schema.- Specified by:
checkCanDropSchemain interfaceAccessControl- Overrides:
checkCanDropSchemain classAccessControlManager
-
checkCanRenameSchema
public void checkCanRenameSchema(SecurityContext context, CatalogSchemaName schemaName, String newSchemaName) Description copied from interface:AccessControlCheck if identity is allowed to rename the specified schema.- Specified by:
checkCanRenameSchemain interfaceAccessControl- Overrides:
checkCanRenameSchemain classAccessControlManager
-
checkCanShowCreateTable
Description copied from interface:AccessControlCheck if identity is allowed to execute SHOW CREATE TABLE, SHOW CREATE VIEW or SHOW CREATE MATERIALIZED VIEW- Specified by:
checkCanShowCreateTablein interfaceAccessControl- Overrides:
checkCanShowCreateTablein classAccessControlManager
-
checkCanCreateTable
public void checkCanCreateTable(SecurityContext context, QualifiedObjectName tableName, Map<String, Object> properties) Description copied from interface:AccessControlCheck if identity is allowed to create the specified table with properties.- Specified by:
checkCanCreateTablein interfaceAccessControl- Overrides:
checkCanCreateTablein classAccessControlManager
-
checkCanDropTable
Description copied from interface:AccessControlCheck if identity is allowed to drop the specified table.- Specified by:
checkCanDropTablein interfaceAccessControl- Overrides:
checkCanDropTablein classAccessControlManager
-
checkCanRenameTable
public void checkCanRenameTable(SecurityContext context, QualifiedObjectName tableName, QualifiedObjectName newTableName) Description copied from interface:AccessControlCheck if identity is allowed to rename the specified table.- Specified by:
checkCanRenameTablein interfaceAccessControl- Overrides:
checkCanRenameTablein classAccessControlManager
-
checkCanSetTableProperties
public void checkCanSetTableProperties(SecurityContext context, QualifiedObjectName tableName, Map<String, Optional<Object>> properties) Description copied from interface:AccessControlCheck if identity is allowed to set properties to the specified table.- Specified by:
checkCanSetTablePropertiesin interfaceAccessControl- Overrides:
checkCanSetTablePropertiesin classAccessControlManager
-
checkCanSetTableComment
Description copied from interface:AccessControlCheck if identity is allowed to comment the specified table.- Specified by:
checkCanSetTableCommentin interfaceAccessControl- Overrides:
checkCanSetTableCommentin classAccessControlManager
-
checkCanSetViewComment
Description copied from interface:AccessControlCheck if identity is allowed to comment the specified view.- Specified by:
checkCanSetViewCommentin interfaceAccessControl- Overrides:
checkCanSetViewCommentin classAccessControlManager
-
checkCanSetColumnComment
Description copied from interface:AccessControlCheck if identity is allowed to comment the specified column.- Specified by:
checkCanSetColumnCommentin interfaceAccessControl- Overrides:
checkCanSetColumnCommentin classAccessControlManager
-
checkCanAddColumns
Description copied from interface:AccessControlCheck if identity is allowed to add columns to the specified table.- Specified by:
checkCanAddColumnsin interfaceAccessControl- Overrides:
checkCanAddColumnsin classAccessControlManager
-
checkCanDropColumn
Description copied from interface:AccessControlCheck if identity is allowed to drop columns from the specified table.- Specified by:
checkCanDropColumnin interfaceAccessControl- Overrides:
checkCanDropColumnin classAccessControlManager
-
checkCanRenameColumn
Description copied from interface:AccessControlCheck if identity is allowed to rename a column in the specified table.- Specified by:
checkCanRenameColumnin interfaceAccessControl- Overrides:
checkCanRenameColumnin classAccessControlManager
-
checkCanAlterColumn
Description copied from interface:AccessControlCheck if identity is allowed to alter columns to the specified table.- Specified by:
checkCanAlterColumnin interfaceAccessControl- Overrides:
checkCanAlterColumnin classAccessControlManager
-
checkCanInsertIntoTable
Description copied from interface:AccessControlCheck if identity is allowed to insert into the specified table.- Specified by:
checkCanInsertIntoTablein interfaceAccessControl- Overrides:
checkCanInsertIntoTablein classAccessControlManager
-
checkCanDeleteFromTable
Description copied from interface:AccessControlCheck if identity is allowed to delete from the specified table.- Specified by:
checkCanDeleteFromTablein interfaceAccessControl- Overrides:
checkCanDeleteFromTablein classAccessControlManager
-
checkCanTruncateTable
Description copied from interface:AccessControlCheck if identity is allowed to truncate the specified table.- Specified by:
checkCanTruncateTablein interfaceAccessControl- Overrides:
checkCanTruncateTablein classAccessControlManager
-
checkCanUpdateTableColumns
public void checkCanUpdateTableColumns(SecurityContext context, QualifiedObjectName tableName, Set<String> updatedColumnNames) Description copied from interface:AccessControlCheck if identity is allowed to update the specified table.- Specified by:
checkCanUpdateTableColumnsin interfaceAccessControl- Overrides:
checkCanUpdateTableColumnsin classAccessControlManager
-
checkCanCreateView
Description copied from interface:AccessControlCheck if identity is allowed to create the specified view.- Specified by:
checkCanCreateViewin interfaceAccessControl- Overrides:
checkCanCreateViewin classAccessControlManager
-
checkCanRenameView
public void checkCanRenameView(SecurityContext context, QualifiedObjectName viewName, QualifiedObjectName newViewName) Description copied from interface:AccessControlCheck if identity is allowed to rename the specified view.- Specified by:
checkCanRenameViewin interfaceAccessControl- Overrides:
checkCanRenameViewin classAccessControlManager
-
checkCanDropView
Description copied from interface:AccessControlCheck if identity is allowed to drop the specified view.- Specified by:
checkCanDropViewin interfaceAccessControl- Overrides:
checkCanDropViewin classAccessControlManager
-
checkCanSetSystemSessionProperty
Description copied from interface:AccessControlCheck if identity is allowed to set the specified system property.- Specified by:
checkCanSetSystemSessionPropertyin interfaceAccessControl- Overrides:
checkCanSetSystemSessionPropertyin classAccessControlManager
-
checkCanCreateViewWithSelectFromColumns
public void checkCanCreateViewWithSelectFromColumns(SecurityContext context, QualifiedObjectName tableName, Set<String> columnNames) Description copied from interface:AccessControlCheck if identity is allowed to create a view that selects from the specified columns.- Specified by:
checkCanCreateViewWithSelectFromColumnsin interfaceAccessControl- Overrides:
checkCanCreateViewWithSelectFromColumnsin classAccessControlManager
-
checkCanCreateMaterializedView
public void checkCanCreateMaterializedView(SecurityContext context, QualifiedObjectName materializedViewName, Map<String, Object> properties) Description copied from interface:AccessControlCheck if identity is allowed to create the specified materialized view.- Specified by:
checkCanCreateMaterializedViewin interfaceAccessControl- Overrides:
checkCanCreateMaterializedViewin classAccessControlManager
-
checkCanRefreshMaterializedView
public void checkCanRefreshMaterializedView(SecurityContext context, QualifiedObjectName materializedViewName) Description copied from interface:AccessControlCheck if identity is allowed to refresh the specified materialized view.- Specified by:
checkCanRefreshMaterializedViewin interfaceAccessControl- Overrides:
checkCanRefreshMaterializedViewin classAccessControlManager
-
checkCanDropMaterializedView
public void checkCanDropMaterializedView(SecurityContext context, QualifiedObjectName materializedViewName) Description copied from interface:AccessControlCheck if identity is allowed to drop the specified materialized view.- Specified by:
checkCanDropMaterializedViewin interfaceAccessControl- Overrides:
checkCanDropMaterializedViewin classAccessControlManager
-
checkCanRenameMaterializedView
public void checkCanRenameMaterializedView(SecurityContext context, QualifiedObjectName viewName, QualifiedObjectName newViewName) Description copied from interface:AccessControlCheck if identity is allowed to rename the specified materialized view.- Specified by:
checkCanRenameMaterializedViewin interfaceAccessControl- Overrides:
checkCanRenameMaterializedViewin classAccessControlManager
-
checkCanSetMaterializedViewProperties
public void checkCanSetMaterializedViewProperties(SecurityContext context, QualifiedObjectName materializedViewName, Map<String, Optional<Object>> properties) Description copied from interface:AccessControlCheck if identity is allowed to set the properties of the specified materialized view.- Specified by:
checkCanSetMaterializedViewPropertiesin interfaceAccessControl- Overrides:
checkCanSetMaterializedViewPropertiesin classAccessControlManager
-
checkCanShowColumns
Description copied from interface:AccessControlCheck if identity is allowed to show columns of tables by executing SHOW COLUMNS, DESCRIBE etc.NOTE: This method is only present to give users an error message when listing is not allowed. The
AccessControl.filterColumns(io.trino.security.SecurityContext, java.lang.String, java.util.Map<io.trino.spi.connector.SchemaTableName, java.util.Set<java.lang.String>>)method must filter all results for unauthorized users, since there are multiple ways to list columns.- Specified by:
checkCanShowColumnsin interfaceAccessControl- Overrides:
checkCanShowColumnsin classAccessControlManager
-
filterColumns
public Map<SchemaTableName,Set<String>> filterColumns(SecurityContext context, String catalogName, Map<SchemaTableName, Set<String>> tableColumns) Description copied from interface:AccessControlFilter lists of columns of multiple tables to those visible to the identity.- Specified by:
filterColumnsin interfaceAccessControl- Overrides:
filterColumnsin classAccessControlManager
-
checkCanSetCatalogSessionProperty
public void checkCanSetCatalogSessionProperty(SecurityContext context, String catalogName, String propertyName) Description copied from interface:AccessControlCheck if identity is allowed to set the specified catalog property.- Specified by:
checkCanSetCatalogSessionPropertyin interfaceAccessControl- Overrides:
checkCanSetCatalogSessionPropertyin classAccessControlManager
-
checkCanSelectFromColumns
public void checkCanSelectFromColumns(SecurityContext context, QualifiedObjectName tableName, Set<String> columns) Description copied from interface:AccessControlCheck if identity is allowed to select from the specified columns. The column set can be empty.- Specified by:
checkCanSelectFromColumnsin interfaceAccessControl- Overrides:
checkCanSelectFromColumnsin classAccessControlManager
-
canExecuteFunction
Description copied from interface:AccessControlIs the identity allowed to execute function?- Specified by:
canExecuteFunctionin interfaceAccessControl- Overrides:
canExecuteFunctionin classAccessControlManager
-
canCreateViewWithExecuteFunction
public boolean canCreateViewWithExecuteFunction(SecurityContext context, QualifiedObjectName functionName) Description copied from interface:AccessControlIs the identity allowed to create a view that executes the specified function?- Specified by:
canCreateViewWithExecuteFunctionin interfaceAccessControl- Overrides:
canCreateViewWithExecuteFunctionin classAccessControlManager
-
checkCanExecuteTableProcedure
public void checkCanExecuteTableProcedure(SecurityContext context, QualifiedObjectName table, String procedure) Description copied from interface:AccessControlCheck if identity is allowed to execute given table procedure on given table- Specified by:
checkCanExecuteTableProcedurein interfaceAccessControl- Overrides:
checkCanExecuteTableProcedurein classAccessControlManager
-
getRowFilters
- Specified by:
getRowFiltersin interfaceAccessControl- Overrides:
getRowFiltersin classAccessControlManager
-
getColumnMask
public Optional<ViewExpression> getColumnMask(SecurityContext context, QualifiedObjectName tableName, String column, Type type) - Specified by:
getColumnMaskin interfaceAccessControl- Overrides:
getColumnMaskin classAccessControlManager
-