-
-
Notifications
You must be signed in to change notification settings - Fork 710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"permissions" propery in metadata for configuring arbitrary permissions #1636
Comments
I keep running into a need for this. Every time I create a new plugin that defines a new permission I wish there was a clean way to grant that permission to new users without installing some other permissions plugin. |
I keep shipping plugins that set a special hook just so the root user can try them out. |
Current design: {
"databases": {
"private": {
"allow": {
"id": "*"
}
}
}
} This can be applied at the instance, database, table or query level within the nested JSON. https://docs.datasette.io/en/stable/authentication.html#controlling-access-to-specific-databases It's actually controlling the following permissions:
There's also a special case for allowing SQL queries,at the instance and database level: {
"databases": {
"mydatabase": {
"allow_sql": {
"id": "root"
}
}
}
} |
So the new mechanism needs to extend that to handle all of the other permissions as well. The simplest design I can think of is this (here illustrated using YAML): # instance-level permissions - give every logged in user the debug menu:
permissions:
debug-menu:
id: *
databases:
content:
# Allow bob to create-table in the content database
permissions:
create-table:
id: bob |
Should I call this key Some options:
|
Also, this is another thing which should live in |
Thankfully all of the logic for this already lives in just one place: datasette/datasette/default_permissions.py Lines 23 to 59 in d7e5e3c
|
I'm going to write the documentation for this first. |
What if you want to grant You should be able to do that by putting that in the root Also: there are some permissions like Ideally the implementation would spot those on startup and refuse to start the server, with a helpful error message. |
First draft of documentation: https://datasette--1938.org.readthedocs.build/en/1938/authentication.html#other-permissions-in-metadata |
I may need to consult this file to figure out if the permission that is being checked can act at the database/table/instance level: datasette/datasette/permissions.py Lines 1 to 19 in e539c1c
|
* Docs for permissions: in metadata, refs #1636 * Refactor default_permissions.py to help with implementation of #1636 * register_permissions() plugin hook, closes #1939 - also refs #1938 * Tests for register_permissions() hook, refs #1939 * Documentation for datasette.permissions, refs #1939 * permission_allowed() falls back on Permission.default, refs #1939 * Raise StartupError on duplicate permissions * Allow dupe permisisons if exact matches
A bunch of the work for this just landed - in particular the new scheme is now documented (even though it doesn't work yet): https://docs.datasette.io/en/latest/authentication.html#other-permissions-in-metadata |
The implementation for this will go here: datasette/datasette/default_permissions.py Lines 81 to 83 in 8bf06a7
Here's the start of the tests (currently marked as datasette/tests/test_permissions.py Lines 652 to 689 in 8bf06a7
|
The thing I'm stuck on at the moment is how to implement it such that an Maybe the algorithm when
So everything is keyed off the incoming |
The
"allow"
block mechanism can already be used to configure various default permissions. When adding permissions todatasette-tiddlywiki
I realized it would be good to be able to configure arbitrary permissions such asedit-tiddlywiki
there too.The text was updated successfully, but these errors were encountered: