Implemented view-instance permission, refs #811

This commit is contained in:
Simon Willison 2020-06-07 14:30:39 -07:00
commit 8571ce388a
2 changed files with 24 additions and 0 deletions

View file

@ -7,6 +7,10 @@ def permission_allowed(datasette, actor, action, resource_type, resource_identif
if action == "permissions-debug":
if actor and actor.get("id") == "root":
return True
elif action == "view-instance":
allow = datasette.metadata("allow")
if allow is not None:
return actor_matches_allow(actor, allow)
elif action == "view-query":
# Check if this query has a "allow" block in metadata
assert resource_type == "query"