Dynamic permissions set from the APIs
Closed this issue · 3 comments
afabiani commented
The goal would be allow the frontend to dynamically set the list of available permissions for a certain resource type
We would like to avoid putting a lot of static conditions on the frontend side in order to render the list above.
The proposal is to:
-
Add a new node to the resource API v2
json
output namedallowed_perms
providing the list of the availableperm_spec
andcompact
permissions on a resource
e.g. for adataset
resource type"allowed_perms": { "perms": [ "change_resourcebase", "change_resourcebase_metadata", "change_resourcebase_permissions", "delete_resourcebase", "download_resourcebase", "publish_resourcebase", "view_resourcebase", "change_dataset_data", "change_dataset_style" ], "compact": [ "view", "download", "edit", "manage", "owner" ] }
-
Allow the frontend to be able to filter the perms
dropdowns
accordingly to the previous list
afabiani commented
Refining the proposal for the backend endpoints
http://localhost:8000/api/v2/resources/resource_types
{
"resource_types": [
{
"name": "dataset",
"count": 1,
"allowed_perms": {
"perms": {
"anonymous": [
"view_resourcebase"
],
"registered-members": [
"change_resourcebase_metadata",
"delete_resourcebase",
"change_resourcebase_permissions",
"publish_resourcebase",
"change_resourcebase",
"view_resourcebase",
"download_resourcebase",
"change_dataset_data",
"change_dataset_style"
]
},
"compact": {
"anonymous": [
"view"
],
"registered-members": [
"view",
"download",
"edit",
"manage"
]
}
}
},
{
"name": "map",
"count": 0,
"allowed_perms": {
"perms": {
"anonymous": [
"view_resourcebase"
],
"registered-members": [
"change_resourcebase_metadata",
"delete_resourcebase",
"change_resourcebase_permissions",
"publish_resourcebase",
"change_resourcebase",
"view_resourcebase"
]
},
"compact": {
"anonymous": [
"view"
],
"registered-members": [
"view",
"edit",
"manage"
]
}
}
},
{
"name": "document",
"count": 0,
"allowed_perms": {
"perms": {
"anonymous": [
"view_resourcebase"
],
"registered-members": [
"change_resourcebase_metadata",
"delete_resourcebase",
"change_resourcebase_permissions",
"publish_resourcebase",
"change_resourcebase",
"view_resourcebase",
"download_resourcebase"
]
},
"compact": {
"anonymous": [
"view"
],
"registered-members": [
"view",
"download",
"edit",
"manage"
]
}
}
},
{
"name": "geostory",
"count": 1,
"allowed_perms": {
"perms": {
"anonymous": [
"view_resourcebase"
],
"registered-members": [
"change_resourcebase_metadata",
"delete_resourcebase",
"change_resourcebase_permissions",
"publish_resourcebase",
"change_resourcebase",
"view_resourcebase"
]
},
"compact": {
"anonymous": [
"view"
],
"registered-members": [
"view",
"edit",
"manage"
]
}
}
},
{
"name": "dashboard",
"count": 0,
"allowed_perms": {
"perms": {
"anonymous": [
"view_resourcebase"
],
"registered-members": [
"change_resourcebase_metadata",
"delete_resourcebase",
"change_resourcebase_permissions",
"publish_resourcebase",
"change_resourcebase",
"view_resourcebase"
]
},
"compact": {
"anonymous": [
"view"
],
"registered-members": [
"view",
"edit",
"manage"
]
}
}
}
]
}
allyoucanmap commented
@afabiani I think the default permission of the resource are missing ?
"allowed_perms": {
"perms": {
"default": [
"change_resourcebase",
"change_resourcebase_metadata",
"change_resourcebase_permissions",
"delete_resourcebase",
"download_resourcebase",
"publish_resourcebase",
"view_resourcebase",
"change_dataset_data",
"change_dataset_style"
],
"anonymous": [
"view_resourcebase"
],
"registered-members": [
"change_resourcebase_metadata",
"delete_resourcebase",
"change_resourcebase_permissions",
"publish_resourcebase",
"change_resourcebase",
"view_resourcebase"
]
},
"compact": {
"default": [
"view",
"download",
"edit",
"manage"
],
"anonymous": [
"view"
],
"registered-members": [
"view",
"edit",
"manage"
]
}
}
afabiani commented
- Backend ticket on GeoNode: GeoNode#8300