Skip to content

Commit 1527762

Browse files
authored
Merge pull request #331 from maykinmedia/feature/324-setup-config-docs
📝 [#324] Update documentation for setup-configuration
2 parents 27ff1fb + 5ae486f commit 1527762

File tree

9 files changed

+65
-94
lines changed

9 files changed

+65
-94
lines changed

docs/conf.py

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import sys
1010

1111
import django
12+
from django.utils.translation import activate
1213

1314
sys.path.insert(0, os.path.abspath("../src"))
1415
os.environ["LOG_REQUESTS"] = "false"
@@ -39,6 +40,9 @@
3940
"sphinx.ext.autodoc",
4041
"sphinx.ext.todo",
4142
"sphinx.ext.intersphinx",
43+
"sphinx.ext.autodoc",
44+
"django_setup_configuration.documentation.setup_config_example",
45+
"django_setup_configuration.documentation.setup_config_usage",
4246
# "sphinx_tabs.tabs",
4347
# "recommonmark",
4448
# "sphinx_markdown_tables",
@@ -54,6 +58,10 @@
5458
# Usually you set "language" from the command line for these cases.
5559
language = "en"
5660

61+
# Also set the language to English for Django, to make sure that any translatable text
62+
# is also shown in English (for instance the help texts for setup configuration examples)
63+
activate("en")
64+
5765
# List of patterns, relative to source directory, that match files and
5866
# directories to ignore when looking for source files.
5967
# This pattern also affects html_static_path and html_extra_path.

docs/installation/setup_configuration.rst

+1-81
Original file line numberDiff line numberDiff line change
@@ -4,84 +4,4 @@
44
Open Klant configuration (CLI)
55
==============================
66

7-
After deploying Open Klant, it needs to be configured to be fully functional.
8-
The django management command ``setup_configuration`` assist with this configuration.
9-
You can get the full command documentation with:
10-
11-
.. code-block:: bash
12-
13-
python ./src/manage.py setup_configuration --help
14-
15-
.. warning:: This command is declarative - if configuration is manually changed after
16-
running the command and you then run the exact same command again, the manual
17-
changes will be reverted.
18-
19-
Preparation
20-
===========
21-
22-
The command executes the list of pluggable configuration steps, and each step
23-
requires specific configuration information, that should be prepared.
24-
Here is the description of all available configuration steps and the configuration
25-
format, used by each step.
26-
27-
Token configuration
28-
----------------------
29-
30-
Create a (single) YAML configuration file with your settings:
31-
32-
.. code-block:: yaml
33-
34-
tokenauth_config_enable: true
35-
tokenauth:
36-
items:
37-
- identifier: token-1
38-
token: ba9d233e95e04c4a8a661a27daffe7c9bd019067
39-
contact_person: Person 1
40-
41-
organization: Organization XYZ # optional
42-
application: Application XYZ # optional
43-
administration: Administration XYZ # optional
44-
45-
- identifier: token-2
46-
token: 7b2b212d9f16d171a70a1d927cdcfbd5ca7a4799
47-
contact_person: Person 2
48-
49-
50-
51-
Mozilla-django-oidc-db
52-
----------------------
53-
54-
Create or update the (single) YAML configuration file with your settings:
55-
56-
.. code-block:: yaml
57-
58-
...
59-
oidc_db_config_enable: true
60-
oidc_db_config_admin_auth:
61-
items:
62-
- identifier: admin-oidc
63-
oidc_rp_client_id: client-id
64-
oidc_rp_client_secret: secret
65-
endpoint_config:
66-
oidc_op_discovery_endpoint: https://keycloak.local/protocol/openid-connect/
67-
...
68-
69-
More details about configuring mozilla-django-oidc-db through ``setup_configuration``
70-
can be found at the _`documentation`: https://mozilla-django-oidc-db.readthedocs.io/en/latest/setup_configuration.html.
71-
72-
Execution
73-
=========
74-
75-
Open Klant configuration
76-
------------------------
77-
78-
With the full command invocation, everything is configured at once. Each configuration step
79-
is idempotent, so any manual changes made via the admin interface will be updated if the command
80-
is run afterwards.
81-
82-
.. code-block:: bash
83-
84-
python ./src/manage.py setup_configuration --yaml-file /path/to/config.yaml
85-
86-
.. note:: Due to a cache-bug in the underlying framework, you need to restart all
87-
replicas for part of this change to take effect everywhere.
7+
.. setup-config-usage::

requirements/base.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ django-sendfile2==0.7.1
151151
# via django-privates
152152
django-sessionprofile==3.0.0
153153
# via open-api-framework
154-
django-setup-configuration==0.4.0
154+
django-setup-configuration==0.7.1
155155
# via
156156
# -r requirements/base.in
157157
# mozilla-django-oidc-db
@@ -184,6 +184,8 @@ djangorestframework-gis==1.0
184184
# via open-api-framework
185185
djangorestframework-inclusions==1.2.0
186186
# via open-api-framework
187+
docutils==0.21.2
188+
# via django-setup-configuration
187189
drf-nested-routers==0.94.1
188190
# via commonground-api-common
189191
drf-spectacular==0.27.2
@@ -232,7 +234,7 @@ maykin-2fa==1.0.1
232234
# via open-api-framework
233235
mozilla-django-oidc==4.0.1
234236
# via mozilla-django-oidc-db
235-
mozilla-django-oidc-db==0.21.1
237+
mozilla-django-oidc-db==0.22.0
236238
# via
237239
# -r requirements/base.in
238240
# open-api-framework
@@ -315,6 +317,10 @@ rpds-py==0.19.1
315317
# via
316318
# jsonschema
317319
# referencing
320+
ruamel-yaml==0.18.10
321+
# via django-setup-configuration
322+
ruamel-yaml-clib==0.2.12
323+
# via ruamel-yaml
318324
sentry-sdk==2.12.0
319325
# via open-api-framework
320326
six==1.16.0

requirements/ci.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
codecov
2+
pytest

requirements/ci.txt

+17-4
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ django-sessionprofile==3.0.0
289289
# -c requirements/base.txt
290290
# -r requirements/base.txt
291291
# open-api-framework
292-
django-setup-configuration==0.4.0
292+
django-setup-configuration==0.7.1
293293
# via
294294
# -c requirements/base.txt
295295
# -r requirements/base.txt
@@ -342,8 +342,11 @@ djangorestframework-inclusions==1.2.0
342342
# -c requirements/base.txt
343343
# -r requirements/base.txt
344344
# open-api-framework
345-
docutils==0.20.1
345+
docutils==0.21.2
346346
# via
347+
# -c requirements/base.txt
348+
# -r requirements/base.txt
349+
# django-setup-configuration
347350
# recommonmark
348351
# sphinx
349352
# sphinx-rtd-theme
@@ -490,7 +493,7 @@ mozilla-django-oidc==4.0.1
490493
# -c requirements/base.txt
491494
# -r requirements/base.txt
492495
# mozilla-django-oidc-db
493-
mozilla-django-oidc-db==0.21.1
496+
mozilla-django-oidc-db==0.22.0
494497
# via
495498
# -c requirements/base.txt
496499
# -r requirements/base.txt
@@ -686,6 +689,16 @@ rpds-py==0.19.1
686689
# -r requirements/base.txt
687690
# jsonschema
688691
# referencing
692+
ruamel-yaml==0.18.10
693+
# via
694+
# -c requirements/base.txt
695+
# -r requirements/base.txt
696+
# django-setup-configuration
697+
ruamel-yaml-clib==0.2.12
698+
# via
699+
# -c requirements/base.txt
700+
# -r requirements/base.txt
701+
# ruamel-yaml
689702
sentry-sdk==2.12.0
690703
# via
691704
# -c requirements/base.txt
@@ -713,7 +726,7 @@ sphinx==7.4.7
713726
# sphinxcontrib-jquery
714727
sphinx-markdown-tables==0.0.17
715728
# via -r requirements/docs.in
716-
sphinx-rtd-theme==2.0.0
729+
sphinx-rtd-theme==3.0.2
717730
# via -r requirements/docs.in
718731
sphinx-tabs==3.4.5
719732
# via -r requirements/docs.in

requirements/dev.txt

+15-4
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ django-sessionprofile==3.0.0
328328
# -c requirements/ci.txt
329329
# -r requirements/ci.txt
330330
# open-api-framework
331-
django-setup-configuration==0.4.0
331+
django-setup-configuration==0.7.1
332332
# via
333333
# -c requirements/ci.txt
334334
# -r requirements/ci.txt
@@ -383,10 +383,11 @@ djangorestframework-inclusions==1.2.0
383383
# -c requirements/ci.txt
384384
# -r requirements/ci.txt
385385
# open-api-framework
386-
docutils==0.20.1
386+
docutils==0.21.2
387387
# via
388388
# -c requirements/ci.txt
389389
# -r requirements/ci.txt
390+
# django-setup-configuration
390391
# recommonmark
391392
# sphinx
392393
# sphinx-rtd-theme
@@ -561,7 +562,7 @@ mozilla-django-oidc==4.0.1
561562
# -c requirements/ci.txt
562563
# -r requirements/ci.txt
563564
# mozilla-django-oidc-db
564-
mozilla-django-oidc-db==0.21.1
565+
mozilla-django-oidc-db==0.22.0
565566
# via
566567
# -c requirements/ci.txt
567568
# -r requirements/ci.txt
@@ -799,6 +800,16 @@ rpds-py==0.19.1
799800
# -r requirements/ci.txt
800801
# jsonschema
801802
# referencing
803+
ruamel-yaml==0.18.10
804+
# via
805+
# -c requirements/ci.txt
806+
# -r requirements/ci.txt
807+
# django-setup-configuration
808+
ruamel-yaml-clib==0.2.12
809+
# via
810+
# -c requirements/ci.txt
811+
# -r requirements/ci.txt
812+
# ruamel-yaml
802813
sentry-sdk==2.12.0
803814
# via
804815
# -c requirements/ci.txt
@@ -839,7 +850,7 @@ sphinx-markdown-tables==0.0.17
839850
# via
840851
# -c requirements/ci.txt
841852
# -r requirements/ci.txt
842-
sphinx-rtd-theme==2.0.0
853+
sphinx-rtd-theme==3.0.2
843854
# via
844855
# -c requirements/ci.txt
845856
# -r requirements/ci.txt

src/openklant/setup_configuration/models.py

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ class Meta:
1616
"administration",
1717
)
1818
}
19+
extra_kwargs = {
20+
"identifier": {"examples": ["open-inwoner"]},
21+
"token": {"examples": ["modify-this"]},
22+
"contact_person": {"examples": ["John Doe"]},
23+
"email": {"examples": ["[email protected]"]},
24+
"organization": {"examples": ["Municipality name"]},
25+
"application": {"examples": ["Open Inwoner"]},
26+
}
1927

2028

2129
class TokenAuthGroupConfigurationModel(ConfigurationModel):

src/openklant/setup_configuration/steps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TokenAuthConfigurationStep(
1616
BaseConfigurationStep[TokenAuthGroupConfigurationModel]
1717
):
1818
"""
19-
Configure configuration groups for the Objects API backend
19+
Configure tokens for other applications to access the APIs provided by Open Klant
2020
"""
2121

2222
namespace = "tokenauth"

src/openklant/setup_configuration/tests/test_token_auth_config.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
from django.test import TestCase
44

5-
from django_setup_configuration.exceptions import ConfigurationRunFailed
5+
from django_setup_configuration.exceptions import (
6+
ConfigurationRunFailed,
7+
PrerequisiteFailed,
8+
)
69
from django_setup_configuration.test_utils import execute_single_step
710

811
from openklant.components.token.models import TokenAuth
@@ -218,7 +221,7 @@ def test_invalid_identifier(self):
218221

219222
test_file_path = str(TEST_FILES / "token_invalid_identifier.yaml")
220223

221-
with self.assertRaises(ConfigurationRunFailed):
224+
with self.assertRaises(PrerequisiteFailed):
222225
execute_single_step(TokenAuthConfigurationStep, yaml_source=test_file_path)
223226

224227
tokens = TokenAuth.objects.order_by("created")

0 commit comments

Comments
 (0)