mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Removed resource_type from permissions system, closes #817
Refs #811, #699
This commit is contained in:
parent
5598c5de01
commit
c9f1ec616e
14 changed files with 39 additions and 89 deletions
|
|
@ -3,7 +3,7 @@ from datasette.utils import actor_matches_allow
|
|||
|
||||
|
||||
@hookimpl
|
||||
def permission_allowed(datasette, actor, action, resource_type, resource_identifier):
|
||||
def permission_allowed(datasette, actor, action, resource_identifier):
|
||||
if action == "permissions-debug":
|
||||
if actor and actor.get("id") == "root":
|
||||
return True
|
||||
|
|
@ -12,13 +12,11 @@ def permission_allowed(datasette, actor, action, resource_type, resource_identif
|
|||
if allow is not None:
|
||||
return actor_matches_allow(actor, allow)
|
||||
elif action == "view-database":
|
||||
assert resource_type == "database"
|
||||
database_allow = datasette.metadata("allow", database=resource_identifier)
|
||||
if database_allow is None:
|
||||
return True
|
||||
return actor_matches_allow(actor, database_allow)
|
||||
elif action == "view-table":
|
||||
assert resource_type == "table"
|
||||
database, table = resource_identifier
|
||||
tables = datasette.metadata("tables", database=database) or {}
|
||||
table_allow = (tables.get(table) or {}).get("allow")
|
||||
|
|
@ -27,7 +25,6 @@ def permission_allowed(datasette, actor, action, resource_type, resource_identif
|
|||
return actor_matches_allow(actor, table_allow)
|
||||
elif action == "view-query":
|
||||
# Check if this query has a "allow" block in metadata
|
||||
assert resource_type == "query"
|
||||
database, query_name = resource_identifier
|
||||
queries_metadata = datasette.metadata("queries", database=database)
|
||||
assert query_name in queries_metadata
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue