Skip to content

Commit 1abe5f7

Browse files
committed
How to grant access to specific columns, closes #98
1 parent 9847eec commit 1abe5f7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/setup.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ TO "my-read-only-role";
4242
```
4343
Think carefully about which tables you expose to the dashboard - in particular, you should avoid exposing tables that contain sensitive data such as `auth_user` or `django_session`.
4444

45+
If you do want to expose `auth_user` - which can be useful if you want to join other tables against it to see details of the user that created another record - you can grant access to specific columns like so:
46+
```sql
47+
GRANT SELECT(
48+
id, last_login, is_superuser, username, first_name,
49+
last_name, email, is_staff, is_active, date_joined
50+
) ON auth_user TO "my-read-only-role";
51+
```
52+
This will allow queries against everything except for the `password` column.
53+
54+
Note that if you use this pattern the query `select * from auth_user` will return a "permission denied" error. You will need to explicitly list the columns you would like to see from that table instead, for example `select id, username, date_joined from auth_user`.
55+
4556
## Configuring the "dashboard" database alias
4657

4758
Django SQL Dashboard defaults to executing all queries using the `"dashboard"` Django database alias.

0 commit comments

Comments
 (0)