-
-
Notifications
You must be signed in to change notification settings - Fork 704
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
Clarify permissions terminology around "resource" #2457
Comments
There are a few other things to consider here. Currently every Datasette permission is either attached to the whole instance, a database or a resource (in the table-or-canned-query definition) within a database. But... it's increasingly likely there may be other things that do NOT belong to a database that still need permissions applied to them, for example:
On that basis, I think "resource" SHOULD be a term that can mean database or table or canned query or group or dashboard or ... As such, the design of that |
It's a bit more complicated than that. The problem is that some resources are children of databases, such that granting e.g. |
If I do change the definition of |
The most important thing about resources is that they need to fit the permissions system at the database level.
If I introduce the concept of a "resource type" maybe that table looks like this instead:
Storing tables as |
The biggest challenge here then is how to cleanly implement permission checks that say "if the user has insert-row on the data/incidents table OR has insert-row on the data database" - how many places would need to implement checks like that? It also relates to this: I'll need to be sure there's a clean, efficient way to say "list all resources that this user has |
It's pretty clear to me that "resource" should mean a database or a table or a query or another type of thing provided by a plugin - so that special treatment for database needs to be cleaned up. But at the same time, the fact that some permissions when applied to databases are inherited by their "child" resources does need to be clarified, both in documentation and at the implementation level. I think the best way to clarify that would be with a development spike that covers both Datasette and datasette-acl, with the goal of implementing efficient view permissions for the list of tables to be shown on the homepage: |
How about if class Permission:
name: str
abbr: Optional[str]
description: Optional[str]
resources: Tuple[str, ...] Then a permission might look like this: Permission(
name="view-table",
abbr="vt",
description="View table",
resources=("database", "table"),
default=True,
implies_can_view=True,
) |
Maybe a |
I like the idea of registering resource classes - maybe with a naming convention like Then could do this: Permission(
name="view-table",
abbr="vt",
description="View table",
resources=(InstanceResource, DatabaseResource, TableResource),
default=True,
implies_can_view=True,
) But when checking permissions could pass instances of them, like |
The term "resource" is not consistently applied within Datasette's permissions code at the moment.
https://github.com/simonw/datasette/blob/d9a450b19797e89d70aec70406ed595d9f14dcc1/docs/authentication.rst defines our permissions model clearly:
But elsewhere a "resource" is a thing that's either a table or a canned query that lives within a database, e.g. here:
datasette/datasette/permissions.py
Lines 5 to 12 in d9a450b
The unclear thing is whether a database itself is a resource or not?
The text was updated successfully, but these errors were encountered: