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.
- python >= 3.6
- CKAN >= 2.9
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
# 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
id: (mandatory) DrupalID of the user
Accepts mandatory id
(DrupalID). The rest of parameters will be
passed to underlying user_show
.
Checks whether user is allowed to get user details by DrupalID. At the moment only sysadmin can pass this check.
* drupal-idp - ckanext-drupal-idp CLI
* user - User management
* list - List all users with DrupalID
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
To run the tests, do:
pytest --ckan-ini=test.ini ckanext/drupal_idp