Skip to content

Commit

Permalink
[#4878] Allow custom CKAN callback URL for the DataPusher
Browse files Browse the repository at this point in the history
The DataPusher pings back CKAN when performing or finishing
a job (calling the datapusher_hook action), and it does so
via an HTTP request to the host defined in ckan.site_url.

There are a number of scenarios where this does not work, eg:

* CKAN and DataPusher sitting behind a Firewall that doesn't
  allow external requests
* Standard Docker compose setup for development where the
  ckan.site_url is http://localhost:5000 or similar

This change adds a new config option that allows to define an
alternative internal URL that DataPusher can reach.
  • Loading branch information
amercader committed Jul 1, 2019
1 parent 7793817 commit 09d2f3b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ckanext/datapusher/logic/action.py
Expand Up @@ -62,7 +62,14 @@ def datapusher_submit(context, data_dict):
datapusher_url = config.get('ckan.datapusher.url')

site_url = h.url_for('/', qualified=True)
callback_url = h.url_for('/api/3/action/datapusher_hook', qualified=True)

callback_url_base = config.get('ckan.datapusher.callback_url_base')
if callback_url_base:
callback_url = urlparse.urljoin(
callback_url_base.rstrip('/'), '/api/3/action/datapusher_hook')
else:
callback_url = h.url_for(
'/api/3/action/datapusher_hook', qualified=True)

user = p.toolkit.get_action('user_show')(context, {'id': context['user']})

Expand Down
16 changes: 16 additions & 0 deletions doc/maintaining/configuration.rst
Expand Up @@ -1490,6 +1490,22 @@ running on port 8800. If you want to manually install the DataPusher, follow
the installation `instructions <http://docs.ckan.org/projects/datapusher>`_.


.. _ckan.datapusher.callback_url_base:

ckan.datapusher.url
^^^^^^^^^^^^^^^^^^^

Example::

ckan.datapusher.callback_url_base = http://ckan:5000/

Default value: Value of ``ckan.site_url``

Alternative callback URL for DataPusher when performing a request to CKAN. This is
useful on scenarios where the host where DataPusher is running can not access the
public CKAN site URL.


.. _ckan.datapusher.assume_task_stale_after:

ckan.datapusher.assume_task_stale_after
Expand Down

0 comments on commit 09d2f3b

Please sign in to comment.