-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ability to manage global permissions #10
Comments
The UI for this is a bit of a challenge. The grid I use for the table only really works there because there aren't many table permissions: Once we get to global permissions there are a whole lot more - and plugins can register their own too. I'm inclined to say each global permission should get its own dedicated page, but in that case a grid of checkboxes doesn't feel right. |
Here's our datasette-acl/datasette_acl/__init__.py Lines 285 to 308 in 01c0e94
|
The UI challenge is solved now that I'm using |
Which actions should apply globally? A couple of options:
I'm going to go for the second option for the moment, I think having actions at the global level may be too confusing. But... I may actually implement support for global permissions like UPDATE: I decided to go with option one instead, since that's what |
An interesting thing to consider here is what happens with permissions that are added by other plugins using the https://docs.datasette.io/en/latest/plugin_hooks.html#register-permissions-datasette hook - reminder, that looks like this: @hookimpl
def register_permissions(datasette):
return [
Permission(
name="upload-csvs",
abbr=None,
description="Upload CSV files",
takes_database=True,
takes_resource=False,
default=False,
)
] |
Since that plugin already decided that all actions can be applied globally, I should have this plugin make the same decision for consistency. |
... but I might NOT show the ones that default to |
Here's the code in "all_permissions": [
{"name": key, "description": value.description}
for key, value in datasette.permissions.items()
if key
not in (
"auth-tokens-create",
"auth-tokens-revoke-all",
"debug-menu",
"permissions-debug",
)
],
"database_permissions": [
{"name": key, "description": value.description}
for key, value in datasette.permissions.items()
if value.takes_database
],
"resource_permissions": [
{"name": key, "description": value.description}
for key, value in datasette.permissions.items()
if value.takes_resource
], |
New SQL query: with actor_groups as (
select group_id
from acl_actor_groups
where actor_id = :actor_id
),
target_resources as (
select id
from acl_resources
where (database = :database and resource = :resource)
or (database = :database and resource = '')
or (database = '' and resource = '')
),
target_action as (
select id
from acl_actions
where name = :action
),
combined_permissions as (
select resource_id, action_id
from acl
where actor_id = :actor_id
union
select resource_id, action_id
from acl
where group_id in (select group_id from actor_groups)
)
select count(*)
from combined_permissions
where resource_id in (select id from target_resources)
and action_id = (select id from target_action) That should work against all levels of resource - per-table, per-database and per-instance, thanks to this bit: target_resources as (
select id
from acl_resources
where (database = :database and resource = :resource)
or (database = :database and resource = '')
or (database = '' and resource = '')
), |
... and I think I can call this exact SQL query with database of empty string and/or resource of empty string to run checks for any kind of arguments passed to the |
Permissions not associated with a resource, like the
datasette-acl
permission itself.The text was updated successfully, but these errors were encountered: