From 09d2f3bb9d6eec436b40be4447aff8c9f3db9786 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 27 Jun 2019 14:10:12 +0200 Subject: [PATCH] [#4878] Allow custom CKAN callback URL for the DataPusher 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. --- ckanext/datapusher/logic/action.py | 9 ++++++++- doc/maintaining/configuration.rst | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ckanext/datapusher/logic/action.py b/ckanext/datapusher/logic/action.py index b530273b2c7..5a5f5196767 100644 --- a/ckanext/datapusher/logic/action.py +++ b/ckanext/datapusher/logic/action.py @@ -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']}) diff --git a/doc/maintaining/configuration.rst b/doc/maintaining/configuration.rst index 91abde5de54..75e668ddb07 100644 --- a/doc/maintaining/configuration.rst +++ b/doc/maintaining/configuration.rst @@ -1490,6 +1490,22 @@ running on port 8800. If you want to manually install the DataPusher, follow the installation `instructions `_. +.. _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