Skip to main content

Extension to allow dataset restriction via CKAN API.

Project description

CKAN Restricted API

Extension to allow dataset restriction via CKAN 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).

Install

pip install ckanext-restricted-api

Config

Optional variables can be set in your ckan.ini:

  • 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 the resource 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 user
      • registered only registered users
      • only_allowed_users only users specified in the allowed_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 comma separated string containing specified allowed users, to be used with only_allowed_users.

Example:

"restricted": '{"level": "same_organization", "allowed_users": ""}'

"only_allowed_users": '{"level": "same_organization", "allowed_users": "user1,user2,user3"}'

Granting Access

  1. Users can request access to a dataset by calling an API endpoint from a frontend.
  2. The package owner is emailed and can allow individual users to access the resource. a. Access can be granted by updating the restricted dict (via the API / frontend).
  3. If access is granted, the user will be notified by email automatically.

Endpoints

POST

GET

Notes

Users who do not have restricted access have two fields redacted:

  • url: to download the dataset
  • restricted: 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ckanext-restricted-api-2.0.3.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

ckanext_restricted_api-2.0.3-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file ckanext-restricted-api-2.0.3.tar.gz.

File metadata

File hashes

Hashes for ckanext-restricted-api-2.0.3.tar.gz
Algorithm Hash digest
SHA256 d90eb6d45b9c62d73531db86610be281c398d788458881dc2550c339a073d8fa
MD5 59f1ca95e7bec68ad3a3bc8115e3e6f0
BLAKE2b-256 87015dd6c6baa8cd126f8cf64b4f81bf5487a62802eaf3a330f9604370850a3c

See more details on using hashes here.

File details

Details for the file ckanext_restricted_api-2.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for ckanext_restricted_api-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 455d61e9ca87702ec368dd94c7737f86f1e762969b87fdf00c74c69c6969fa81
MD5 1ddb10f37875d278bead57111a5aca04
BLAKE2b-256 04015cd225a94824f20a1544a7a47f76d4be8fd0902ecfeb90ad4cff0561d484

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page