explorerhq / explorerhq/sql-explorer
Feature request: Block access to certain tables
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 373
- PR merge metrics
- No merged PRs in 30d
Description
Similar to the `EXPLORER_SQL_BLACKLIST`, I would love a feature that would enable blocking queries to specific tables (e.g. auth_user, authtoken_token, django_session, etc.). I know the correct way to do this is to only grant select access to the correct tables for the read only database account being used for the SQL Explorer connection. But as with `EXPLORER_SQL_BLACKLIST`, in some use cases, setting those permissions may not be available.
Sample logic:
```
def passes_table_blacklist(sql: str) -> Tuple[bool, Iterable[str]]:
blocked_tables = getattr(settings, 'EXPLORER_TABLE_BLACKLIST', [])
failed_tables = [table.upper() for table in blocked_tables if table.upper() in sql.upper()]
return bool(failed_tables), failed_tables
```
Compare to [passes_blacklist](https://github.com/explorerhq/sql-explorer/blob/910cb710ab4015d3ad32e4c63b9263e7381bd19f/explorer/utils.py#L22).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.