Extension to allow dataset restriction via CKAN API.
Project description
CKAN Restricted API
Documentation: https://envidat.gitlab-pages.wsl.ch/ckanext-restricted_api/
Source Code: https://gitlabext.wsl.ch/EnviDat/ckanext-restricted_api
This plugin is primarily intended for custom frontends built on the CKAN API.
Requires CKAN >= 2.10. For <2.10, use ckanext-restricted-api==1.0.0
- Restrict the accessibility to the resources of a dataset.
- This way the package metadata is accesible but not the data itself (resource).
- The resource access restriction level can be individualy defined for every package.
Based on work by @espona (Lucia Espona Pernas) for ckanext-restricted (https://github.com/EnviDat/ckanext-restricted).
Granting Access
- Users can request access to a dataset by calling an API endpoint from a frontend.
- The package owner is emailed and can allow individual users to access the resource.
- If access is granted, the user will be notified by email.
Install
pip install ckanext-restricted-api
Config
Optional variables can be set in your ckan.ini:
TBC
- restricted_api.access_request_template
- Description: Path to access request template to render as html email.
- Default: uses default template.
- restricted_api.access_granted_template
- Description: Path to access granted template to render as html email.
- Default: uses default template.
The Restricted Dict
-
This plugin works by storing information in the
extra
field of theresource
table in CKAN. -
By default, CKAN extras values are extracted into the package/resource JSONs returned by the API.
-
The key
restricted
is stored, with a value containing a nested dictionary of:- level: a string containing the restriction level, with options:
public
any userregistered
only registered usersonly_allowed_users
only users specified in theallowed_users
key.any_organization
any user that is a member in an organisation.same_organization
only users of the same organisation the dataset is within.
- allowed_users: a list containing specified allowed users, to be used with
only_allowed_users
.
- level: a string containing the restriction level, with options:
Example:
"restricted": '{"level": "same_organization", "allowed_users": ""}'
"only_allowed_users": '{"level": "same_organization", "allowed_users": ["user1", "user2"]}'
Endpoints
POST
GET
Notes
Users who do not have restricted access have two fields redacted:
url
: to download the datasetrestricted
: to see the restriction information
Downloading of the restricted resource is also not possible via the CKAN API.
However, it should be noted, if resources are hosted in public S3 storage, then this obfuscation does not prevent direct download of the data.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ckanext-restricted-api-2.0.0.tar.gz
.
File metadata
- Download URL: ckanext-restricted-api-2.0.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.8.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1254ffb9cb6f1543b2642b7d5109df55945014829ce8c8765c3517b3c2e7ed1 |
|
MD5 | 25c5b0d186eda4e13eb56806a99516cc |
|
BLAKE2b-256 | 0a9cb4eb9a8444800010dab555a829229ec3dbf08f95ab7fa53586ce1f906b5c |
File details
Details for the file ckanext_restricted_api-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: ckanext_restricted_api-2.0.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.8.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99df272e8c3f6c82af6fa02c4bf732987bc39eb17b43db18000d8a37f04e3eed |
|
MD5 | 9dce567fe31cd91f0b7ce153b6bb474e |
|
BLAKE2b-256 | b7687c4de3cdc2a20427ec0fbea21e69627d27136a647590614b6af758987b20 |