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
|
|
@ -70,8 +70,8 @@ def check_permission_actions_are_documented():
|
|||
action = kwargs.get("action").replace("-", "_")
|
||||
assert (
|
||||
action in documented_permission_actions
|
||||
), "Undocumented permission action: {}, resource_type: {}, resource_identifier: {}".format(
|
||||
action, kwargs["resource_type"], kwargs["resource_identifier"]
|
||||
), "Undocumented permission action: {}, resource_identifier: {}".format(
|
||||
action, kwargs["resource_identifier"]
|
||||
)
|
||||
|
||||
pm.add_hookcall_monitoring(
|
||||
|
|
|
|||
|
|
@ -857,24 +857,21 @@ if __name__ == "__main__":
|
|||
|
||||
|
||||
def assert_permissions_checked(datasette, actions):
|
||||
# actions is a list of "action" or (action, resource_type, resource_identifier) tuples
|
||||
# actions is a list of "action" or (action, resource_identifier) tuples
|
||||
for action in actions:
|
||||
if isinstance(action, str):
|
||||
resource_type = None
|
||||
resource_identifier = None
|
||||
else:
|
||||
action, resource_type, resource_identifier = action
|
||||
action, resource_identifier = action
|
||||
assert [
|
||||
pc
|
||||
for pc in datasette._permission_checks
|
||||
if pc["action"] == action
|
||||
and pc["resource_type"] == resource_type
|
||||
and pc["resource_identifier"] == resource_identifier
|
||||
], """Missing expected permission check: action={}, resource_type={}, resource_identifier={}
|
||||
], """Missing expected permission check: action={}, resource_identifier={}
|
||||
Permission checks seen: {}
|
||||
""".format(
|
||||
action,
|
||||
resource_type,
|
||||
resource_identifier,
|
||||
json.dumps(list(datasette._permission_checks), indent=4),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue