使用Drupal会话cookie登录CKAN
项目描述
ckanext-drupal-idp
当可用的Drupal会话cookie时,用于用户认证。使用Drupal的DB创建缺少的用户,当用户详情在Drupal端更改时(条件性)同步字段。
需求
- python >= 3.6
- CKAN >= 2.9
安装
要安装ckanext-drupal-idp
-
激活您的CKAN虚拟环境,例如
. /usr/lib/ckan/default/bin/activate
-
克隆源并将其安装在虚拟env上
git clone https://github.com/DataShades/ckanext-drupal-idp.git cd ckanext-drupal-idp pip install -e .
-
将
drupal-idp
添加到您的CKAN配置文件中的ckan.plugins
设置(默认情况下,配置文件位于/etc/ckan/default/ckan.ini
)。 -
配置Drupal的DB
ckanext.drupal_idp.db_url = <URL>
-
重新启动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.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 61d3bbfde8adc9cdef83365db1641f012741d4e72a8bc5020b4ae749eea3bb8c |
|
MD5 | 1cdce6ed52a78563f02aca6c46c483dc |
|
BLAKE2b-256 | c76a62708c3b7ec5c4df86e2721abc0796dfbc47fa4e8a4d85edc69e811a6b31 |
关闭
ckanext_drupal_idp-0.4.5-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 556b51531c6a911f971e4b5b15dcf4bbac09a87e99570b73d2e06bc4abaa84fa |
|
MD5 | 9c3fd4a879bcbb536cd61e4c27f1f5a0 |
|
BLAKE2b-256 | 336f6acd644056c9a36c88d6a57b3148ddc6c43ff86852207cc8d9debb200c23 |