diff --git a/.env.example b/.env.example index 6adbb1e0..9c23a5c8 100644 --- a/.env.example +++ b/.env.example @@ -31,6 +31,15 @@ CKAN_REDIS_URL=redis://redis:6379/1 CKAN_DATAPUSHER_URL=http://datapusher:8800 CKAN__DATAPUSHER__CALLBACK_URL_BASE=http://ckan:5000 +# If the "expire_api_token" plugin is enabled we need to define +# "expires_in" and "unit" parameters +DATAPUSHER_TOKEN_EXPIRES_IN= +DATAPUSHER_TOKEN_EXPIRES_UNIT= +# example for 1 year +# DATAPUSHER_TOKEN_EXPIRES_IN=365 +# unit=1:Second;unit=2:Minute;unit=3:Hour;unit=4:Day +# DATAPUSHER_TOKEN_EXPIRES_UNIT=4 + TEST_CKAN_SOLR_URL=http://solr:8983/solr/ckan TEST_CKAN_REDIS_URL=redis://redis:6379/1 diff --git a/ckan-base/2.10/Dockerfile b/ckan-base/2.10/Dockerfile index aa753543..8f5ff255 100644 --- a/ckan-base/2.10/Dockerfile +++ b/ckan-base/2.10/Dockerfile @@ -16,6 +16,10 @@ ENV CKAN__PLUGINS image_view text_view recline_view datastore datapusher envvars # UWSGI options ENV UWSGI_HARAKIRI=50 +# optional. If the "expire_api_token" is enabled you will need this. +ENV DATAPUSHER_TOKEN_EXPIRES_IN= +ENV DATAPUSHER_TOKEN_EXPIRES_UNIT= + WORKDIR ${APP_DIR} # Install necessary packages to run CKAN diff --git a/ckan-base/2.10/setup/start_ckan.sh b/ckan-base/2.10/setup/start_ckan.sh index 7be25392..30d57662 100755 --- a/ckan-base/2.10/setup/start_ckan.sh +++ b/ckan-base/2.10/setup/start_ckan.sh @@ -20,8 +20,21 @@ fi sudo -u ckan -EH python3 prerun.py # Set a proper value for ckan.datapusher.api_token now that that an admin user exists + +# If the expire_api_token plugin is enabled you will need to define +# "expires_in" and "unit" parameters. If required, add +# DATAPUSHER_TOKEN_EXPIRES_IN and DATAPUSHER_TOKEN_EXPIRES_UNIT as env +# variables. +if [[ -n "$DATAPUSHER_TOKEN_EXPIRES_IN" ]] +then + TOKEN_EXTRAS="expires_in=$DATAPUSHER_TOKEN_EXPIRES_IN unit=$DATAPUSHER_TOKEN_EXPIRES_UNIT" +else + TOKEN_EXTRAS="" +fi + +expires_in=30 unit=4 echo "Set up ckan.datapusher.api_token" -ckan config-tool $CKAN_INI "ckan.datapusher.api_token=$(ckan -c $CKAN_INI user token add ckan_admin datapusher | tail -n 1 | tr -d '\t')" +ckan config-tool $CKAN_INI "ckan.datapusher.api_token=$(ckan -c $CKAN_INI user token add ckan_admin datapusher $TOKEN_EXTRAS | tail -n 1 | tr -d '\t')" # Run any startup scripts provided by images extending this one if [[ -d "/docker-entrypoint.d" ]]