Skip to content

Commit

Permalink
🚧 add yaml example to step
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Jan 3, 2025
1 parent c632590 commit 08a59c9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 15 deletions.
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ python:
extra_requirements:
- tests
- docs
- setup-configuration
8 changes: 8 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 1 addition & 14 deletions docs/setup_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
37 changes: 37 additions & 0 deletions mozilla_django_oidc_db/setup_configuration/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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+https://github.com/maykinmedia/django-setup-configuration.git@feature/embed-model-examples",
]
tests = [
"psycopg2",
Expand Down

0 comments on commit 08a59c9

Please sign in to comment.