Skip to main content

Login to CKAN using Drupal session cookie

Project description

Tests

ckanext-drupal-idp

When Drupal's session cookie is available use it for user authentication. Create missing users, using data from Drupal's DB and synchronize(conditionally) fields when user details changed on Drupal's side.

Requirements

  • python >= 3.6
  • CKAN >= 2.9

Installation

To install ckanext-drupal-idp:

  1. Activate your CKAN virtual environment, for example:

     . /usr/lib/ckan/default/bin/activate
    
  2. Clone the source and install it on the virtualenv

     git clone https://github.com/DataShades/ckanext-drupal-idp.git
     cd ckanext-drupal-idp
     pip install -e .
    
  3. Add drupal-idp to the ckan.plugins setting in your CKAN config file (by default the config file is located at /etc/ckan/default/ckan.ini).

  4. Configure Drupal's DB:

     ckanext.drupal_idp.db_url = <URL>
    
  5. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:

     sudo service apache2 reload
    

Config settings

# ckanext-drupal-idp
# Defines database used by the Drupal application
# (mandatory).
ckanext.drupal_idp.db_url = mysql://drupal_user:drupal_pass@127.0.0.1:3306/db_name

# Whether to make an attempt to synchronize user's details everytime
# session is used. This may result in unauthenticated session if new name or email
# already present in CKAN database
# (optional, default: false).
ckanext.drupal_idp.synchronization.enabled = true

# Configure hostname of the drupal instance statically. Usefull for local testing with
# manually added cookie from any accessible drupal instance
# (optional)
ckanext.drupal_idp.host = my.site.com

# Whether to set sysadmin flag on the user who has Drupal's admin role
# (optional, default: false)
ckanext.drupal_idp.admin_role.inherit = true

# Name of the role that grants sysadmin status
# (optional, default: administrator)
ckanext.drupal_idp.admin_role.name = administrator

# When user created, set his ID to the same value as DrupalID
# (optional, default: false)
ckanext.drupal_idp.same_id = true

# Custom Drupal fields that shold be synchronized as well
# (optional, default: [])
ckanext.drupal_idp.extra_fields = field_age field_xxx

# Skip user identification during static requests(css/js)
# (optional, default: false)
ckanext.drupal_idp.skip_static = yes

API actions

drupal_idp_user_show

Parameters:
id: (mandatory) DrupalID of the user
Details:

Accepts mandatory id(DrupalID). The rest of parameters will be passed to underlying user_show.


Auth functions

drupal_idp_user_show

Details:

Checks whether user is allowed to get user details by DrupalID. At the moment only sysadmin can pass this check.


CLI

* drupal-idp - ckanext-drupal-idp CLI
  * user - User management
    * list - List all users with DrupalID

Developer installation

To install ckanext-drupal-idp for development, activate your CKAN virtualenv and do:

git clone https://github.com/DataShades/ckanext-drupal-idp.git
cd ckanext-drupal-idp
python setup.py develop
pip install -r dev-requirements.txt

Tests

To run the tests, do:

pytest --ckan-ini=test.ini ckanext/drupal_idp

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-drupal-idp-0.3.3.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

ckanext_drupal_idp-0.3.3-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file ckanext-drupal-idp-0.3.3.tar.gz.

File metadata

  • Download URL: ckanext-drupal-idp-0.3.3.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for ckanext-drupal-idp-0.3.3.tar.gz
Algorithm Hash digest
SHA256 9ee6269d85a6cd7d88252fa9ad0e99b8872b5c105f4adc927a5225556b1bf566
MD5 e4b7967c9d1ff7b6cb7ef6f58281e437
BLAKE2b-256 5f7d9d65285b28249ccaf515bd523eb475998b043b19b0bb7645805c3edd7ac6

See more details on using hashes here.

File details

Details for the file ckanext_drupal_idp-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: ckanext_drupal_idp-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for ckanext_drupal_idp-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 444b18ad669b4f151fc5fd6d60acf0c02eca3634355ae3f241bd9689b4931d0a
MD5 f2a0d166477b3bb9c89241ee263fbb6f
BLAKE2b-256 0152b301b0bea8bcad4bf8b382ecafa7f35c8af3098fe8e072bbab2bd52f5ed6

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