def _datasource_access_by_name( self, database: "Database", table_name: str, schema: str = None ) -> bool: """ Return True if the user can access the SQL table, False otherwise. :param database: The SQL database :param table_name: The SQL table name :param schema: The Superset schema :returns: Whether the use can access the SQL table """ from superset import db if self.database_access(database) or self.all_datasource_access(): return True schema_perm = self.get_schema_perm(database, schema) if schema_perm and self.can_access("schema_access", schema_perm): return True datasources = ConnectorRegistry.query_datasources_by_name( db.session, database, table_name, schema=schema ) for datasource in datasources: if self.can_access("datasource_access", datasource.perm): return True return False
def datasource_access_by_name( self, database, datasource_name, schema=None): if self.database_access(database) or self.all_datasource_access(): return True schema_perm = utils.get_schema_perm(database, schema) if schema and self.can_access('schema_access', schema_perm): return True datasources = ConnectorRegistry.query_datasources_by_name( db.session, database, datasource_name, schema=schema) for datasource in datasources: if self.can_access("datasource_access", datasource.perm): return True return False
def datasource_access_by_name( self, database, datasource_name, schema=None): if self.database_access(database) or self.all_datasource_access(): return True schema_perm = utils.get_schema_perm(database, schema) if schema and self.can_access('schema_access', schema_perm): return True datasources = ConnectorRegistry.query_datasources_by_name( db.session, database, datasource_name, schema=schema) for datasource in datasources: if self.can_access('datasource_access', datasource.perm): return True return False