Skip to content

Commit

Permalink
Cioos Release 1.3.0 (#174)
Browse files Browse the repository at this point in the history
* Rename lib/io.py module which was giving problems

* Rename __init__.py file in extension

* Show job title on job start/finish log messages

To make it easier to debug background job calls.

Before:

```
INFO  [ckan.lib.jobs] Worker rq:worker:f0792c8bd67344f288b5704d39c43124 starts job 2baa42e5-4582-4103-92e5-b4a384d0b1da from queue "default"
```

After:

```
INFO  [ckan.lib.jobs] Worker rq:worker:f0792c8bd67344f288b5704d39c43124 starts job 2baa42e5-4582-4103-92e5-b4a384d0b1da (Process data fields) from queue "default"
```

* Add missing __init__.py file

* String literals

* snippet names rendered in non-debug mode

* Update changelog for 2.9.4

* Build frontend

* [i18n] Pull po files from Transifex

* [i18n] Compile mo files

* Upgrade version for 2.9.4

* Update version for 2.9.5b

* Consistent cli behavior

* pep8

* Py2 compatible fix for ckan#6135

* [ckan#6390] fix user create/edit email validators

* Allow strict types for user/group uploads

CKAN 2.9 specific changes when cherry-picking:

* Replace f-strings with .format()
* Don't use faker / Pillow for tests, as there is no faker fixture in
the Python 2 version

* Add changelog entry for group image types

* Move type verification into upload method

* Fix APIToken CLI test

* Update docs

* Link to config options from changelog

* Allow children for select2

* Fix children type

* [ckan#6531] Py2/py3 compatible version of open

* Add select2 features

* Undo change

* Replace f-string

* Fix standards

* [ckan#6530] Add Solr 8 support

* Set logging level to error in error mail handler

* Add RootPathMiddleware to flask stack to support non-root installs running on python 3

* Add previously removed RootPathMiddleware back to common middleware as it is still needed

* Added utility functions for common CKAN admin commands.

* Use correct auth function when editing organizations

* [ckan#5820] fix invite user with existing email error

* Fix regression when validating resource subfields (by @TomeCirun)

* [ckan#6408] Add timeout param to request get calls (by @EricSoroos)

* [ckan#6408] Document new options

* Accept empty string in one of validator

* Negate empty string check

* Fix pep8

* [i18n] Pull translation from Transifex

* [i18n] Compile mo files

* Compile frontend

* Small fix adding virtual env path to ckan command.

* Update changelog before 2.9.5

* Include the Solr 8 schema file in the 2.9 branch

* Update version for 2.9.5

* Update version for 2.9.6b

* Unpin pytz (ckan#6665)

* Pytz is a stable package, and should always be at the most recent version

* Pin zope.interface to a more recent version (ckan#6665)

* Supports py3 > 3.5
* Allows for modern setuptools > 44.1

* fix errno2

* Add Dockerfile.py3 based on d9a49a8

* Check if locale exists on i18n JS API

* Add test and changelog

* Updates to ckan_utils.sh.

* move spatial harvester into ckanext-cioos_harvest extension and allow POST requests to the spatial search api endpoint in the spatial api

* document spatil harvester config

* update submodules

* create dev branch in submodules and update

* remove extra comma

(cherry picked from commit fb27f2a)

* Fixing tests.

* --passthrough-errors overrides conflicting options

* Describe --passthrough-errors

* Add --passthrough-errors example inside docker-compose.yml

* Disable reloader when passthrough_errors is set

* Add --host 0.0.0.0 to pdb example

* add try/except block when creating test data

* add compile css command

* check for data before attempting to create it again

* upgrade solr to 8.11.1

* update

* update all submodules to latest dev version

* update submodules again

* update schema

* Updated submodule contrib/docker/src/ckanext-cioos_theme

* Updated submodule contrib/docker/src/ckanext-spatial

* fix a few integration bugs

* update

* Updated submodule contrib/docker/src/ckanext-cioos_theme

* update translations

* fix bugs, update logos

* Updated submodule contrib/docker/src/ckanext-scheming

* add atlantic eov icons

* Updated submodule contrib/docker/src/ckanext-cioos_theme

* add collapsed option to indicate how truncated fields initially load

* add wasRevisionOf to schema.org profile output

* release all submodules -  merge dev into main

* remove geoview pip file from dockerfile

* Merge branch 'cioos' into cioos_dev
Removed submodule contrib/docker/src/ckanext-cioos_theme

* Fixes a two errors when dealing with a encoded url.

* url in question /%EF%AC%81?foo=bar&bz=%AC%81
* This is a unicode character, which can't be decoded from
ascii. Jinja templates will handle this if it's unicode, or if it's
hex encoded ascii, but can't take a non-unicode string in python 2 and
put this in a template.
* The querystring was being quoted, which is incorrect, as:
  1) the special characters in the query string mean something
  2) The rest of the querystring is already quoted. This makes it
  double quoted, as seen in the datastore file
* We don't want to unquote urls before putting them in the template
anyway.
* There was s further error passing this unicode path to the template
resolution, where in posix path, it fails:
```
File '/usr/lib/ckan/default/lib/python2.7/posixpath.py', line 73 in join
  path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1: ordinal not in range(128)
```
The solution here is to make sure it's unicode passed into the
function.

* check for resource

* Fix urlparse function call

* [ckan#6948] Avoid storing the session on each request

Override the `is_null_session()` method on our own custom
`BeakerSessionInterface` class to take into account that Beaker always
adds two keys to the session.

* [ckan#6948] Add tests to ensure we don't create unneeed sessions

Move the BeakerSessionInterface class to make testing easier

* [ckan#6948] pep8

* [ckan#6948] prefix literal

* [ckan#6948] Add more keys for Beaker==1.11.0 (py3)

* [ckan#6948] Prefixes

* [ckan#6948] Cross-py version compatible fix

* [ckan#6948] line too long

* [ckan#6948] [ckan#6984] More elegant check, thanks @ThrawnCA

* [ckan#6948] pep8

* update

* update

* Fix additional casting error (str(unicode)->ascii decode error)

* add helper csrf_input

* replaced package_read with package_show

* [ckan#5727] Fix datapusher trigger in case of resource_update without changing URL but using new file via API

The notify method in the IResourceUrlChange will be triggered only
when the URL is changed or if we do the resource update via the API
_submit_to_datapusher will not be triggered and cause the old preview to be displayed.

* [ckan#5727] Add the changelog

* add organization facets

* Expose check_ckan_version to templates

* add try/except block when creating test data

* check for data before attempting to create it again

* Return zero results instead of raising NotFound when vocabulary does not exist

* [ckan#5822] Update sqlparse version

* reorder resource view button: allow translation

* check if dir already exists

* lint

* remove white space

* Exclude site_user from user_list

* Remove typing from cherry-pick

* [QOL-8368] fix race condition in creating the default site user

- creating the user is idempotent so just ignore the error

* [ckan#6649] gettext not for metadata fields

* [ckan#6743] Include root_path in activity email notifications

* [ckan#5857] Extract translations from emails

* Improve error when downloading resource

* Views return 403 for NotAuthorized

* [ckan#6838] Use the headers Reply-to value if its set in the extensions

* Fix broken URL in migration docs

* ckan_config test mark works with request context

* Fix caching logic on logged in users

* [ckan#6892] Fix member delete

* Fix relative import

* Handle missing resources in activity stream

* [ckan#6439] Concurrent-safe resource updates

* Fix tests after ckan#6820

* lint

* Fix tests after ckan#6618

* prefixes

* Remove duplicated class

* add auth functions for 17 actions that didn't have them before

* add bilingual support to resource names

* fix formatting to satisfy linter

* remove new auth functions from blacklist

* add auth function for recently_changed_packages_activity_list

* remove recently_changed_packages_activity_list from blacklist

* document sitemap generation

* add sitemap url to docs

* [2.9] Bump markdown requirement to support Python 3.9

* update psycopg2 to support PostgreSQL 12, ckan#5796

* [ckan#6789] Fix error when listing tokens in the CLI in py2

* [ckan#6519] Use get_action in patch actions to allow custom logic

* [ckan#6658] Fix not_empty validator to allow falsy values

* [ckan#6956] Prevent non-sysadmin users to change their own state

* [i18n] Pull translations from Transifex for 2.9.6

* [i18n] Compile mo files

* Add user_patch action

Needed for the ckan#6956 fix

* Fix patch for ckan#6956

* Frontend build

* lint

* Fix resource file size not updating with resource_patch

* Added changelog fragment

* [ckan#6817] Fix theme settings

* Replace characters in url

* Fix url check location

* Use user id in auth cookie rather than name

* [ckan#6815] Allow get_translated helper to fall back to base version of a language

* lint

* lint2

* Updated submodule contrib/docker/src/ckanext-cioos_theme

* Update CHANGELOG before 2.9.6

* Update version for 2.9.6

* Update version for 2.9.7b

* Updated submodule contrib/docker/src/ckanext-spatial

* Revert deletion portions of f9084f9

* Restores main_css as an app global
* Restores helpsrs.get_rtl_theme

* Reset the form after downloading

* Perform checks on provided id when creating user

* [ckan#7149] Fix organization delete form (via @Zharktas)

* Update changelog

* Update version for 2.9.7

* fix install docs

* add support for multilingual resource description and name

* make uri's more visible in the interface

* make uri handling more robust and clean up org about page

* fix translations

* merge in subrepo changes

* update sub repos

* match eov labels to munged  keywords

* add missing organization uri display in media grid view

* add fq to organization_list api endpoint

example query ```/api/3/action/organization_list?q=hakai&all_fields=true&include_extras=true&fq=-organization-uri:code"_ "",&fq=organization-uri:__```

* upgrade postgis to 3.3

* document organization_list fq addition

* add matching on org uri during harvest.
consolidate uri fields into code field when possible.

* update submodules

* Updates to functions in ckan_utils.sh.

* add harvest object delete chunk instructions

* Remove duplicate function, minor edits on ckan_utils.sh.

* fix organization matching on UID during ckan harvest

* Update the production.ini as variable, and change ec dump/load to generic functions.

* Minor fix to ckan_utils.sh.

* Updated submodule contrib/docker/src/ckanext-cioos_harvest

* update delete harvest objects by chunks code

* upgrade ckanext-harvest tp 1.4.1

* adjust get_fully_qualified_package_uri

* update submodules

* better populate resources during a cioos ckan harvest

* allow round brackets in keywords

* Updated submodule contrib/docker/src/ckanext-cioos_theme

* add tips to instructions doc

* [#175] Add or relocate volumes for solr and redis data in docker-compose files (#176)

* update pacific css

* add WSP logo

Co-authored-by: amercader <amercadero@gmail.com>
Co-authored-by: Sergey Motornyuk <sergey.motornyuk@linkdigital.com.au>
Co-authored-by: calexandr <cherniavskyi.alexandr@linkdigital.com.au>
Co-authored-by: Andres Vazquez <andres@data99.com.ar>
Co-authored-by: Francesco Frassinelli <francesco.frassinelli@nina.no>
Co-authored-by: Jari Voutilainen <jari.voutilainen@iki.fi>
Co-authored-by: Teemu Erkkola <teemu.erkkola@gofore.com>
Co-authored-by: Jeff Cullis <jcullis@dal.ca>
Co-authored-by: Eric Soroos <eric@derilinx.com>
Co-authored-by: cirun <bitola@Bitolas-MacBook-Pro.local>
Co-authored-by: Tome Cirun <cirun@live.com>
Co-authored-by: Tomasz Sabała <tomek@fjelltopp.org>
Co-authored-by: Sergey <tonnydexter@gmail.com>
Co-authored-by: hq-ods <hao.qin@ontario.ca>
Co-authored-by: Shubham Mahajan <mr.shubhammahajan@gmail.com>
Co-authored-by: Sunny-NEC <t_sunny.malik@india.nec.com>
Co-authored-by: Ian Ward <ian@excess.org>
Co-authored-by: Tome Cirun <cirun@pop-os.localdomain>
Co-authored-by: ThrawnCA <shell_layer-github@yahoo.com.au>
Co-authored-by: pdelboca <patriciodelboca@gmail.com>
Co-authored-by: Knud Möller <dunken69@gmail.com>
Co-authored-by: antuarc <carl.antuar@smartservice.qld.gov.au>
Co-authored-by: Konstantin Sivakov <konstantin.sivakov@gmail.com>
Co-authored-by: Jari Voutilainen <jari-pekka.voutilainen@gofore.com>
Co-authored-by: I G Borrelli <44072946+ItaloBorrelli@users.noreply.github.com>
  • Loading branch information
1 parent 161ab79 commit 0b0e786
Show file tree
Hide file tree
Showing 133 changed files with 13,341 additions and 1,576 deletions.
78 changes: 76 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,80 @@ Changelog

.. towncrier release notes start
v.2.9.7 2022-10-26
==================

Bugfixes
--------

* CVE-2022-43685: fix potential user account takeover via user create
* Fix Datatables view download format selector (`#7147 <https://github.com/ckan/ckan/pull/7147>`_)
* Revert deletions included in 2.9.6 as part of #6187 (`#7118 <https://github.com/ckan/ckan/pull/7118>`_)


v.2.9.6 2022-09-28
==================

Note: This release includes requirements upgrades to address security issues


Bugfixes
--------

- Fixes incorrectly encoded url current_url (`#6685 <https://github.com/ckan/ckan/pull/6685>`_)
- Check if locale exists on i18n JS API (`#6698 <https://github.com/ckan/ckan/pull/6698>`_)
- Add ``csrf_input()`` helper for cross-CKAN version compatibilty (`#7016 <https://github.com/ckan/ckan/issues/7016>`_)
- Fix not empty validator (`#6658 <https://github.com/ckan/ckan/pull/6658>`_)
- Use ``get_action()`` in patch actions to allow custom logic (`#6519 <https://github.com/ckan/ckan/pull/6519>`_)
- Allow to extend organization_facets (`#6682 <https://github.com/ckan/ckan/pull/6682>`_)
- Expose check_ckan_version to templates (`#6741 <https://github.com/ckan/ckan/pull/6741>`_)
- Allow get_translated helper to fall back to base version of a language (`#6815 <https://github.com/ckan/ckan/pull/6815>`_)
- Fix server error in tag autocomplete when vocabulary does not exist (`#6820 <https://github.com/ckan/ckan/pull/6820>`_)
- Check if locale exists on i18n JS API (`#6698 <https://github.com/ckan/ckan/pull/6698>`_)
- Fix updating a non-existing resource causes an internal sever error (`#6928 <https://github.com/ckan/ckan/pull/6928>`_)
- Remove extra comma (`#6774 <https://github.com/ckan/ckan/pull/6774>`_)
- Fix test data creation issues (`#6805 <https://github.com/ckan/ckan/pull/6805>`_)
- Fix for updating non-existing resource
- Avoid storing the session on each request (`#6954 <https://github.com/ckan/ckan/pull/6954>`_)
- Return zero results instead of raising NotFound when vocabulary does not exist
- Fix the datapusher trigger in case of resource_update via API (`#5727 <https://github.com/ckan/ckan/pull/5727>`_)
- Consistent CLI behavior when when no command provided and when using `--help` options (`#6120 <https://github.com/ckan/ckan/pull/6120>`_)
- Fix regression when validating resource subfields (`#6546 <https://github.com/ckan/ckan/pull/6546>`_)
- Fix resource file size not updating with resource_patch (`#7075 <https://github.com/ckan/ckan/pull/7076>`_)
- Prevent non-sysadmin users to change their own state (`#6956 <https://github.com/ckan/ckan/pull/6956>`_)
- Use user id in auth cookie rather than name
- Reorder resource view button: allow translation (`#6089 <https://github.com/ckan/ckan/pull/6089>`_)
- Optmize temp dir creation on uploads (`#6578 <https://github.com/ckan/ckan/pull/6578>`_)
- Exclude site_user from user_listi (`#6618 <https://github.com/ckan/ckan/pull/6618>`_)
- Fix race condition in creating the default site user (`#6638 <https://github.com/ckan/ckan/pull/6638>`_)
- gettext not for metadata fields (`#6660 <https://github.com/ckan/ckan/pull/6660>`_)
- Include root_path in activity email notifications (`#6743 <https://github.com/ckan/ckan/pull/6743>`_)
- Extract translations from emails (`#5857 <https://github.com/ckan/ckan/pull/5857>`_)
- Use the headers Reply-to value if its set in the extensions (`#6838 <https://github.com/ckan/ckan/pull/6838>`_)
- Improve error when downloading resource (`#6832 <https://github.com/ckan/ckan/pull/6832>`_)
- ``ckan_config`` test mark works with request context (`#6868 <https://github.com/ckan/ckan/pull/6868>`_)
- Fix caching logic on logged in users (`#6864 <https://github.com/ckan/ckan/pull/6864>`_)
- Fix member delete (`#6892 <https://github.com/ckan/ckan/pull/6892>`_)
- Concurrent-safe resource updates (`#6439 <https://github.com/ckan/ckan/pull/6439>`_)
- Fix error when listing tokens in the CLI in py2 (`#6789 <https://github.com/ckan/ckan/pull/6789>`_)



Minor changes
-------------

- The ``ckan.main_css`` and ``ckan.i18.rtl_css`` settings, which were not working, have been replaced by :ref:`ckan.theme` and :ref:`ckan.i18n.rtl_theme` respectively. Both expect the name of an *asset* with a base theme for the application (`#6817 <https://github.com/ckan/ckan/pull/6817>`_)
- The type of uploads for group and user image can be restricted via the `ckan.upload.{object_type}.types` and `ckan.upload.{object_type}.mimetypes` config options (eg :ref:`ckan.upload.group.types`, :ref:`ckan.upload.user.mimetypes`) (`#6477 <https://github.com/ckan/ckan/pull/6477>`_)
- Allow to use PDB and IDE debuggers (`#6798 <https://github.com/ckan/ckan/pull/6798>`_)
- Unpin pytz, upgrade zope.interface (`#6665 <https://github.com/ckan/ckan/pull/6665>`_)
- Update sqlparse version
- Bump markdown requirement to support Python 3.9
- Update psycopg2 to support PostgreSQL 12
- Add auth functions for 17 actions that didn't have them before (`#7045 <https://github.com/ckan/ckan/pull/7045>`_)
- Add no-op ``csrf_input()`` helper to help extensions with cross-CKAN version suport (`#7030 <https://github.com/ckan/ckan/pull/7030>`_)



v.2.9.5 2022-01-19
==================

Expand Down Expand Up @@ -313,8 +387,8 @@ Migration notes
migrate_package_activity.py like this::

cd /usr/lib/ckan/default/src/ckan/
wget https://raw.githubusercontent.com/ckan/ckan/3484_revision_ui_removal2/ckan/migration/migrate_package_activity.py
wget https://raw.githubusercontent.com/ckan/ckan/3484_revision_ui_removal2/ckan/migration/revision_legacy_code.py
wget https://raw.githubusercontent.com/ckan/ckan/2.9/ckan/migration/migrate_package_activity.py
wget https://raw.githubusercontent.com/ckan/ckan/2.9/ckan/migration/revision_legacy_code.py
python migrate_package_activity.py -c /etc/ckan/production.ini

Future versions of CKAN are likely to need a slightly different procedure.
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ RUN chown -R ckan:ckan $CKAN_HOME $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH
COPY ./contrib/docker/src/ckanext-dcat/requirements.txt $CKAN_VENV/src/ckanext-dcat/requirements.txt
RUN /bin/bash -c "source $CKAN_VENV/bin/activate && cd $CKAN_VENV/src && ckan-pip install -r ckanext-dcat/requirements.txt"

COPY ./contrib/docker/src/ckanext-harvest/pip-requirements.txt $CKAN_VENV/src/ckanext-harvest/pip-requirements.txt
RUN /bin/bash -c "source $CKAN_VENV/bin/activate && cd $CKAN_VENV/src && ckan-pip install -r ckanext-harvest/pip-requirements.txt"
COPY ./contrib/docker/src/ckanext-harvest/requirements.txt $CKAN_VENV/src/ckanext-harvest/requirements.txt
RUN /bin/bash -c "source $CKAN_VENV/bin/activate && cd $CKAN_VENV/src && ckan-pip install -r ckanext-harvest/requirements.txt"

COPY ./contrib/docker/src/ckanext-spatial/requirements.txt $CKAN_VENV/src/ckanext-spatial/requirements.txt
RUN /bin/bash -c "source $CKAN_VENV/bin/activate && cd $CKAN_VENV/src && ckan-pip install -r ckanext-spatial/requirements.txt"
Expand Down
78 changes: 78 additions & 0 deletions Dockerfile.py3
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# See CKAN docs on installation from Docker Compose on usage
FROM ubuntu:focal-20210119
MAINTAINER Open Knowledge

# Set timezone
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Setting the locale
ENV LC_ALL=en_US.UTF-8
RUN apt-get update
RUN apt-get install --no-install-recommends -y locales
RUN sed -i "/$LC_ALL/s/^# //g" /etc/locale.gen
RUN dpkg-reconfigure --frontend=noninteractive locales
RUN update-locale LANG=${LC_ALL}

# Install required system packages
RUN apt-get -q -y update \
&& DEBIAN_FRONTEND=noninteractive apt-get -q -y upgrade \
&& apt-get -q -y install \
python3.6 \
python3-dev \
python3-pip \
python3-venv \
python3-wheel \
libpq-dev \
libxml2-dev \
libxslt-dev \
libgeos-dev \
libssl-dev \
libffi-dev \
postgresql-client \
build-essential \
git-core \
vim \
wget \
curl \
&& apt-get -q clean \
&& rm -rf /var/lib/apt/lists/*

# Define environment variables
ENV CKAN_HOME /usr/lib/ckan
ENV CKAN_VENV $CKAN_HOME/venv
ENV CKAN_CONFIG /etc/ckan
ENV CKAN_STORAGE_PATH=/var/lib/ckan

# Build-time variables specified by docker-compose.yml / .env
ARG CKAN_SITE_URL

# Create ckan user
RUN useradd -r -u 900 -m -c "ckan account" -d $CKAN_HOME -s /bin/false ckan

# Setup virtual environment for CKAN
RUN mkdir -p $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH && \
python3 -m venv $CKAN_VENV && \
ln -s $CKAN_VENV/bin/pip3 /usr/local/bin/ckan-pip3 &&\
ln -s $CKAN_VENV/bin/ckan /usr/local/bin/ckan

# Virtual environment binaries/scripts to be used first
ENV PATH=${CKAN_VENV}/bin:${PATH}

# Setup CKAN
ADD . $CKAN_VENV/src/ckan/
RUN ckan-pip3 install -U pip && \
ckan-pip3 install --upgrade --no-cache-dir -r $CKAN_VENV/src/ckan/requirement-setuptools.txt && \
ckan-pip3 install --upgrade --no-cache-dir -r $CKAN_VENV/src/ckan/requirements.txt && \
ckan-pip3 install -e $CKAN_VENV/src/ckan/ && \
ln -s $CKAN_VENV/src/ckan/ckan/config/who.ini $CKAN_CONFIG/who.ini && \
cp -v $CKAN_VENV/src/ckan/contrib/docker/ckan-entrypoint.sh /ckan-entrypoint.sh && \
chmod +x /ckan-entrypoint.sh && \
chown -R ckan:ckan $CKAN_HOME $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH

ENTRYPOINT ["/ckan-entrypoint.sh"]

USER ckan
EXPOSE 5000

CMD ["ckan","-c","/etc/ckan/production.ini", "run", "--host", "0.0.0.0"]
40 changes: 4 additions & 36 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,40 +84,8 @@ ckan menu create --url [path to wordpress api endpoint] --output [output menu l
sudo docker exec -u root -it ckan ckan --config /etc/ckan/production.ini menu create --url https://cioospacific.ca/wp-json/ra/menu/ --output /menu/pacific_menu_list.html
```

## Troubleshooting
# organization_list api end point
added a fq paramiter to organization_list so that results can be filtered on fields other then name, description, and title.
not queries are supported by adding a negative sign in front of the field name.

If you enter an improper value into the config interface you may *accidentally* lock yourself out of it. If this happens you'll need to update the values by using the CKAN API with an [authorization token](https://ckan.readthedocs.io/en/2.9/api/index.html#authentication-and-api-tokens).

**NOTE:** If you do not have the `api_token.jwt.encode.secret`, `api_token.jwt.decode.secret` and `beaker.session.secret` fields specified in **production.ini** then you will get an error message when you try to generate a token.

A token will still be generated but will not be displayed to you, which is less than helpful.

### Generating an Authorization token

Substitute `[username]` with the username of the user you want to generate a token for, the `[token_name]` field is an arbitrary value to describe the purpose of the token.

Do not be surprised if the generated token is quite long.

```bash
sudo docker exec -it ckan ckan --config /etc/ckan/production.ini user token add [username] [token_name]
```

### Updating config settings using the CKAN API

Now that you have an authorization token you can use the `config_option_update` command to update your CKAN configuration. To see what values you can alter at runtime make a call to the `config_option_list` command. Both commands require an authorization token or you'll get a permission denied error.

Configuration updates must be in the form of JSON as per the example below.

**NOTE:** Substitute `XXX` below with your authorization token.

Get list of configuration options that can be updated:

```bash
curl -H "Authorization: XXX" http://localhost:5000/api/action/config_option_list
```

Example of updating a configuration value

```bash
curl -H "Authorization: XXX" http://localhost:5000/api/action/config_option_update -d "{\"ckan.header_file_name\": \"/menu/atlantic_menu_list.html\"}"
```
example query ```/api/3/action/organization_list?q=hakai&all_fields=true&include_extras=true&fq=-organization-uri:code"_ "",&fq=organization-uri:__```
Loading

0 comments on commit 0b0e786

Please sign in to comment.