diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 02394be..a047a87 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -19,3 +19,4 @@ python: extra_requirements: - tests - docs + - setup-configuration diff --git a/docs/conf.py b/docs/conf.py index 5751f7d..92bb8a0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,6 +22,14 @@ django.setup() +from django_setup_configuration.documentation.directives import ( + InjectValidatedExample, +) + + +def setup(app): + app.add_directive("inject-validated-example", InjectValidatedExample) + # -- Project information ----------------------------------------------------- project = "mozilla_django_oidc_db" diff --git a/docs/setup_configuration.rst b/docs/setup_configuration.rst index 1bfdecb..90054aa 100644 --- a/docs/setup_configuration.rst +++ b/docs/setup_configuration.rst @@ -39,20 +39,7 @@ The setup configuration source must contain the following base keys to use this Example: *setup_config.yml* -.. code-block:: YAML - - other_enable: True - other_config: - ... - oidc_db_config_enable: True - oidc_db_config_admin_auth: - items: - - identifier: admin-oidc - oidc_rp_client_id: client-id - oidc_rp_client_secret: secret - endpoint_config: - oidc_op_discovery_endpoint: https://keycloak.local/protocol/openid-connect/ - ... +.. inject-validated-example:: mozilla_django_oidc_db.setup_configuration.steps.AdminOIDCConfigurationStep This is file is then used with the setup configuration command setup the OIDC admin: diff --git a/mozilla_django_oidc_db/setup_configuration/steps.py b/mozilla_django_oidc_db/setup_configuration/steps.py index b37ef96..72e3bec 100644 --- a/mozilla_django_oidc_db/setup_configuration/steps.py +++ b/mozilla_django_oidc_db/setup_configuration/steps.py @@ -10,6 +10,42 @@ from mozilla_django_oidc_db.utils import get_groups_by_name +EXAMPLE = """\ +oidc_db_config_enable: True +oidc_db_config_admin_auth: + items: + - identifier: admin-oidc + enabled: True + oidc_rp_client_id: testid + oidc_rp_client_secret: 7DB3KUAAizYCcmZufpHRVOcD0TOkNO3I + oidc_rp_scopes_list: + - openid + - email + - profile + oidc_rp_sign_algo: RS256 + endpoint_config: + oidc_op_discovery_endpoint: http://keycloak.open-forms.local:8080/realms/test/ + username_claim: + - sub + groups_claim: + - roles + claim_mapping: + first_name: + - given_name + sync_groups: true + sync_groups_glob_pattern: "*" + default_groups: + - Functioneel beheer + make_users_staff: true + superuser_group_names: + - superuser + oidc_use_nonce: true + oidc_nonce_size: 32 + oidc_state_size: 32 + userinfo_claims_source: id_token +""" + + class AdminOIDCConfigurationStep(BaseConfigurationStep[AdminOIDCConfigurationModel]): """ Configure admin login via OpenID Connect @@ -19,6 +55,7 @@ class AdminOIDCConfigurationStep(BaseConfigurationStep[AdminOIDCConfigurationMod config_model = AdminOIDCConfigurationModel namespace = "oidc_db_config_admin_auth" enable_setting = "oidc_db_config_enable" + example = EXAMPLE def execute(self, model: AdminOIDCConfigurationModel) -> None: if len(model.items) != 1: diff --git a/pyproject.toml b/pyproject.toml index dc9f459..2af923e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ Changelog = "https://github.com/maykinmedia/mozilla-django-oidc-db/blob/master/C [project.optional-dependencies] setup-configuration = [ - "django-setup-configuration>=0.4.0", + "django-setup-configuration @ git+ssh://git@github.com/maykinmedia/django-setup-configuration#feature/embed-model-examples", ] tests = [ "psycopg2",