A Simple Exentension that allows you to use your ckan apikeys with geoserver-authkey extension. sysadmin will have the ability to add and remove roles from a user using the new geoserver_roles tab located on the user read page.
A running geoserver instance with geoserver authkey module installed.
Compatibility with core CKAN versions:
CKAN version | Compatible? |
---|---|
2.6 and earlier | not tested |
2.7 | not tested |
2.8 | not tested |
2.9 | yes |
To install ckanext-geoserver_webservice:
-
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/[email protected]/ckanext-geoserver_webservice.git cd ckanext-geoserver_webservice pip install -e . pip install -r requirements.txt
-
Add
geoserver_webservice
to theckan.plugins
setting in your CKAN config file (by default the config file is located at/etc/ckan/default/ckan.ini
). -
Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
# geoserver instance url
ckanext.geoserver_webservice.url = http://localhost:8080/geoserver
# geoserver user to fetch role options
ckanext.geoserver_webservice.username = admin
# password for geoserver user
ckanext.geoserver_webservice.password = geoserver
# A List of default roles that will be available to all ckan users.
ckanext.geoserver_webservice.default_roles = CKAN
# whether a user can view roles they have assinged to them
ckanext.geoserver_webservice.user_view_roles = false
To install ckanext-geoserver_webservice for development, activate your CKAN virtualenv and do:
git clone https://github.com/[email protected]/ckanext-geoserver_webservice.git
cd ckanext-geoserver_webservice
python setup.py develop
pip install -r dev-requirements.txt
In geoserver GUI goto security > Users, Groups, Roles and add a new group service. Select AuthKEY WebService Body Response and input these details into the correct fields.
name: ckan_webservice_group
password encryption: digest
password policy: default
Web Service Response Roles Search Regular Expression: ^.?"roles"\s:\s*"([^\"]+)".*$
In geoserver GUI goto security > Authentication and add a new Authentication Filter. Select AuthKEY as Authentication filter type input these details into the correct fields.
name: ckan_authkey_filter
name of url parameter: authkey
authentication key to use mapper: Web Service
web Service URL: http://<your_ckan_instance>/api/3/action/geoserver_webservice?authkey={key}
web service response user search regular expression: ^.?"username"\s:\s*"([^\"]+)".*$
read timeout: 10
connection timeout: 5
user/group service: ckan_webservice_group
Now you will just need to create some roles and data access rules.
To run the tests, do:
pytest --ckan-ini=test.ini
If ckanext-geoserver_webservice should be available on PyPI you can follow these steps to publish a new version:
-
Update the version number in the
setup.py
file. See PEP 440 for how to choose version numbers. -
Make sure you have the latest version of necessary packages:
pip install --upgrade setuptools wheel twine
-
Create a source and binary distributions of the new version:
python setup.py sdist bdist_wheel && twine check dist/*
Fix any errors you get.
-
Upload the source distribution to PyPI:
twine upload dist/*
-
Commit any outstanding changes:
git commit -a git push
-
Tag the new release of the project on GitHub with the version number from the
setup.py
file. For example if the version number insetup.py
is 0.0.1 then do:git tag 0.0.1 git push --tags