Skip to content

Commit

Permalink
♻️[#114] make config key names lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
Coperh committed Nov 27, 2024
1 parent dfbfe29 commit 49d035c
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 35 deletions.
18 changes: 9 additions & 9 deletions docs/setup_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,30 @@ Configuration Settings YAML:
============================


The setup configuration admin must contain the following base keys to use setup configuration:
The setup configuration file must contain the following base keys to use this setup configuration step:

* ``OIDC_DB_CONFIG_ENABLE``: enable setup configuration step boolean
* ``oidc_db_config_enable``: enable setup configuration step boolean

* ``OIDC_DB_SETUP_CONFIG_ADMIN_AUTH``: Dictionary that maps OIDC fields to their values.
* ``oidc_db_config_admin_auth``: Dictionary that maps OIDC fields to their values.


Example:

.. code-block:: YAML
OTHER_ENABLE: True
OTHER_CONFiG:
other_enable: True
other_config:
...
OIDC_DB_CONFIG_ENABLE: True
OIDC_DB_SETUP_CONFIG_ADMIN_AUTH:
oidc_db_config_enable: True
oidc_db_config_admin_auth:
oidc_rp_client_id: client-id
oidc_rp_client_secret: secret
endpoint_config:
oidc_op_discovery_endpoint: https://keycloak.local/protocol/openid-connect/
...
Any field from the ``OpenIDConnectConfig`` can be added to ``OIDC_DB_SETUP_CONFIG_ADMIN_AUTH`` (except endpoints, see below)
Any field from the ``OpenIDConnectConfig`` can be added to ``oidc_db_config_admin_auth`` (except endpoints, see below)

Required Fields:
""""""""""""""""
Expand All @@ -79,7 +79,7 @@ Providing both will cause the validation to fail.

Optional Fields:
""""""""""""""""
All the following keys are placed in the ``OIDC_DB_SETUP_CONFIG_ADMIN_AUTH`` dictionary.
All the following keys are placed in the ``oidc_db_config_admin_auth`` dictionary.

* ``oidc_op_jwks_endpoint``: URL of your OpenID Connect provider JSON Web Key Set endpoint.
Required if ``RS256`` is used as signing algorithm. No default value.
Expand Down
4 changes: 2 additions & 2 deletions mozilla_django_oidc_db/setup_configuration/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AdminOIDCConfigurationStep(BaseConfigurationStep[AdminOIDCConfigurationMod

verbose_name = "Configuration for admin login via OpenID Connect"
config_model = AdminOIDCConfigurationModel
namespace = "OIDC_DB_SETUP_CONFIG_ADMIN_AUTH"
enable_setting = "OIDC_DB_CONFIG_ENABLE"
namespace = "oidc_db_config_admin_auth"
enable_setting = "oidc_db_config_enable"

def execute(self, model: AdminOIDCConfigurationModel) -> None:

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]
setupconfig = [
"django-setup-configuration@git+https://github.com/maykinmedia/django-setup-configuration.git@ba0ed8a14acf0ffe05244f53b78fb343c6e5c3df",
"django-setup-configuration@git+https://github.com/maykinmedia/django-setup-configuration.git@c3cb480223d23d1220bd4aca0c57eb07aacaf637",
]
tests = [
"psycopg2",
Expand Down
4 changes: 2 additions & 2 deletions tests/setupconfig/files/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OIDC_DB_CONFIG_ENABLE: True
OIDC_DB_SETUP_CONFIG_ADMIN_AUTH:
oidc_db_config_enable: True
oidc_db_config_admin_auth:
oidc_rp_client_id: client-id
oidc_rp_client_secret: secret
endpoint_config:
Expand Down
4 changes: 2 additions & 2 deletions tests/setupconfig/files/discovery.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OIDC_DB_CONFIG_ENABLE: True
OIDC_DB_SETUP_CONFIG_ADMIN_AUTH:
oidc_db_config_enable: True
oidc_db_config_admin_auth:
oidc_rp_client_id: testid
oidc_rp_client_secret: 7DB3KUAAizYCcmZufpHRVOcD0TOkNO3I
endpoint_config:
Expand Down
4 changes: 2 additions & 2 deletions tests/setupconfig/files/discovery_disabled.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OIDC_DB_CONFIG_ENABLE: False
OIDC_DB_SETUP_CONFIG_ADMIN_AUTH:
oidc_db_config_enable: False
oidc_db_config_admin_auth:
oidc_rp_client_id: testid
oidc_rp_client_secret: 7DB3KUAAizYCcmZufpHRVOcD0TOkNO3I
endpoint_config:
Expand Down
4 changes: 2 additions & 2 deletions tests/setupconfig/files/empty.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
OIDC_DB_CONFIG_ENABLE: True
OIDC_DB_SETUP_CONFIG_ADMIN_AUTH: {}
oidc_db_config_enable: True
oidc_db_config_admin_auth: {}
4 changes: 2 additions & 2 deletions tests/setupconfig/files/full_setup.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OIDC_DB_CONFIG_ENABLE: True
OIDC_DB_SETUP_CONFIG_ADMIN_AUTH:
oidc_db_config_enable: True
oidc_db_config_admin_auth:
oidc_rp_client_id: client-id
oidc_rp_client_secret: secret
oidc_rp_scopes_list:
Expand Down
4 changes: 2 additions & 2 deletions tests/setupconfig/files/partial_endpoints.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OIDC_DB_CONFIG_ENABLE: True
OIDC_DB_SETUP_CONFIG_ADMIN_AUTH:
oidc_db_config_enable: True
oidc_db_config_admin_auth:
oidc_rp_client_id: client-id
oidc_rp_client_secret: secret
endpoint_config:
Expand Down
17 changes: 6 additions & 11 deletions tests/setupconfig/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,9 @@ def test_required_settings():
command_error.value
)

assert "OIDC_DB_SETUP_CONFIG_ADMIN_AUTH.oidc_rp_client_id" in str(
command_error.value
)
assert "OIDC_DB_SETUP_CONFIG_ADMIN_AUTH.oidc_rp_client_secret" in str(
command_error.value
)
assert "OIDC_DB_SETUP_CONFIG_ADMIN_AUTH.endpoint_config" in str(command_error.value)
assert "oidc_db_config_admin_auth.oidc_rp_client_id" in str(command_error.value)
assert "oidc_db_config_admin_auth.oidc_rp_client_secret" in str(command_error.value)
assert "oidc_db_config_admin_auth.endpoint_config" in str(command_error.value)

config = OpenIDConnectConfig.get_solo()
assert not config.enabled
Expand All @@ -116,12 +112,11 @@ def test_partial_endpoints_provided():
)

assert (
"OIDC_DB_SETUP_CONFIG_ADMIN_AUTH.endpoint_config.all.oidc_op_token_endpoint"
"oidc_db_config_admin_auth.endpoint_config.all.oidc_op_token_endpoint"
in str(command_error.value)
)
assert (
"OIDC_DB_SETUP_CONFIG_ADMIN_AUTH.endpoint_config.all.oidc_op_user_endpoint"
in str(command_error.value)
assert "oidc_db_config_admin_auth.endpoint_config.all.oidc_op_user_endpoint" in str(
command_error.value
)

config = OpenIDConnectConfig.get_solo()
Expand Down

0 comments on commit 49d035c

Please sign in to comment.