Login to CKAN using Drupal session cookie
Project description
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:
-
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
-
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 .
-
Add
drupal-idp
to theckan.plugins
setting in your CKAN config file (by default the config file is located at/etc/ckan/default/ckan.ini
). -
Configure Drupal's DB:
ckanext.drupal_idp.db_url = <URL>
-
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
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
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-drupal-idp-0.3.1.tar.gz
.
File metadata
- Download URL: ckanext-drupal-idp-0.3.1.tar.gz
- Upload date:
- Size: 24.8 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50e6dfb35814f67eef4f2e094fea6aafa228b161d430589c3c33b0309aa53048 |
|
MD5 | d70e319aaefba37c67f75654d549932b |
|
BLAKE2b-256 | 6b7236e520f9d8ba63ad177c8d11eb9af48a4300f16dca325b796dc2eb3e1fad |
File details
Details for the file ckanext_drupal_idp-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: ckanext_drupal_idp-0.3.1-py3-none-any.whl
- Upload date:
- Size: 27.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2afa0d145ba9bb2e6356176078ae7e577a3a3d59cbb06c1926cb9956b1f0ca12 |
|
MD5 | a3bd146333db9768aabeb8c0c82c2324 |
|
BLAKE2b-256 | 5a88e8447aee238bda7c63fc5dfb98716f14650a339ee9f285db29892ab37f9b |