Skip to main content

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.
  • ckanext.restricted_api.omit_resources_on_pkg_list
    • Description: on current_package_list_with_resources omit resources completely, or process them all to restrict fields (this may not be performant).
    • Default: True (to maximise performance).

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.

Metadata

Release files for ckanext-restricted_api 2.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ckanext-restricted_api 2.0.6
File Size Uploaded Provenance Actions
ckanext-restricted-api-2.0.6.tar.gz 12.5 kB Without provenance Details for ckanext-restricted-api-2.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ckanext-restricted_api 2.0.6
File Interpreter ABI Platform Actions
ckanext_restricted_api-2.0.6-py3-none-any.whl Python 3 none any Details for ckanext_restricted_api-2.0.6-py3-none-any.whl

Total release size: 25.8 kB

Release files / ckanext-restricted-api-2.0.6.tar.gz

Download URL ckanext-restricted-api-2.0.6.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bce5400a59c5264c91438f01c804753e9bed91e5ab93f99a871b4251fab5d35d
BLAKE2b-256 checksum
How to use checksums
80a6d2e0e57d656921329708097322984ce0f815ec10e82ce2c5782a66593ff6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.8.2 CPython/3.9.18

Release files / ckanext_restricted_api-2.0.6-py3-none-any.whl

Download URL ckanext_restricted_api-2.0.6-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41b66e93441dfd3f9564fe8f594236144e4cf7a5dec95a85b8994b32e83c4461
BLAKE2b-256 checksum
How to use checksums
8ce63c10d77e4c33fbcbbfc23ceb70b6b940b56b838260ece00d848c8236d8a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.8.2 CPython/3.9.18

Security for ckanext-restricted_api 2.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page