跳转到主要内容

使用Drupal会话cookie登录CKAN

项目描述

Tests

ckanext-drupal-idp

当可用的Drupal会话cookie时,用于用户认证。使用Drupal的DB创建缺少的用户,当用户详情在Drupal端更改时(条件性)同步字段。

需求

  • python >= 3.6
  • CKAN >= 2.9

安装

要安装ckanext-drupal-idp

  1. 激活您的CKAN虚拟环境,例如

     . /usr/lib/ckan/default/bin/activate
    
  2. 克隆源并将其安装在虚拟env上

     git clone https://github.com/DataShades/ckanext-drupal-idp.git
     cd ckanext-drupal-idp
     pip install -e .
    
  3. drupal-idp添加到您的CKAN配置文件中的ckan.plugins设置(默认情况下,配置文件位于/etc/ckan/default/ckan.ini)。

  4. 配置Drupal的DB

     ckanext.drupal_idp.db_url = <URL>
    
  5. 重新启动CKAN。例如,如果您在Ubuntu上使用Apache部署CKAN

     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

API操作

drupal_idp_user_show

参数
id: (mandatory) DrupalID of the user
详情

接受强制性的id(DrupalID)。其余参数将传递给底层的user_show


认证函数

drupal_idp_user_show

详情

检查用户是否允许通过DrupalID获取用户详情。目前只有sysadmin可以通过此检查。


CLI

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

开发安装

要为开发安装ckanext-drupal-idp,激活您的CKAN虚拟env并执行

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

测试

要运行测试,执行

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

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源分发

ckanext-drupal-idp-0.4.5.tar.gz (25.7 kB 查看哈希值)

上传时间

构建分发

ckanext_drupal_idp-0.4.5-py3-none-any.whl (28.1 kB 查看哈希值)

上传时间 Python 3

由以下支持