Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [#2263] Setup configuration steps for authentication #1137

Merged
merged 10 commits into from
Apr 19, 2024

Conversation

stevenbal
Copy link
Contributor

@stevenbal stevenbal commented Apr 5, 2024

task: https://taiga.maykinmedia.nl/project/open-inwoner/task/2263

Implements setup configuration for:

  • DigiD & eHerkenning via OpenID Connect
  • Admin login via OpenID connect
  • DigiD & eHerkenning via SAML

I also removed the old DigiD SAML settings, because they have been deprecated: https://github.com/maykinmedia/django-digid-eherkenning/blob/master/CHANGELOG.rst#050-2022-10-31

@stevenbal stevenbal marked this pull request as draft April 5, 2024 07:54
@stevenbal stevenbal force-pushed the feature/2263-setup-config-auth branch 5 times, most recently from 4c5e48a to c0ff93f Compare April 11, 2024 09:07
@stevenbal stevenbal force-pushed the feature/2263-setup-config-auth branch 2 times, most recently from 10a4e55 to 94b94b6 Compare April 15, 2024 07:31
@stevenbal stevenbal force-pushed the feature/2263-setup-config-auth branch 4 times, most recently from 2b73dc5 to 9058681 Compare April 15, 2024 12:53
@stevenbal stevenbal changed the title 🚧 [#2263] setup config for auth ✨ [#2263] Setup configuration steps for authentication Apr 15, 2024
for setting in self.all_settings:
value = getattr(settings, setting, None)
if value is not None:
model_field_name = setting.split("DIGID_OIDC_")[1].lower()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rely on the name being prefixed by DIGID_OIDC_ and the rest of the variable name being identical to the name of the model field. Some fields on the config start with oidc_, that's why some settings contain OIDC_ twice (e.g. DIGID_OIDC_OIDC_RP_CLIENT_ID).

@stevenbal stevenbal force-pushed the feature/2263-setup-config-auth branch 2 times, most recently from 510b9b3 to 35b40ac Compare April 15, 2024 13:13
@stevenbal stevenbal marked this pull request as ready for review April 15, 2024 13:15
@stevenbal stevenbal force-pushed the feature/2263-setup-config-auth branch from 35b40ac to 58da371 Compare April 15, 2024 14:05
required_settings = [
"DIGID_OIDC_OIDC_RP_CLIENT_ID",
"DIGID_OIDC_OIDC_RP_CLIENT_SECRET",
# NOTE these are part of the model, but not actually part of the admin form
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this in some of the other config setup steps too. Perhaps we should decide if we want to expose these variables (then un-comment) or not (then delete the commented out code).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added them to the form and removed the comments

src/open_inwoner/configurations/bootstrap/auth.py Outdated Show resolved Hide resolved
f"Something went wrong while saving configuration: {form.errors}"
)

form.save()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other places, form.save() is wrapped in try/except, here it it is not.

Copy link
Contributor Author

@stevenbal stevenbal Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SAML models can throw ValidationErrors from methods called in .save() (https://github.com/maykinmedia/django-digid-eherkenning/blob/master/digid_eherkenning/models/base.py#L215), but the OIDC form/models don't do this (validation happens during form.is_valid instead)

Copy link
Contributor

@Bartvaderkin Bartvaderkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this mixes regular settings with one-time configuration settings? Can we somehow split that in the code? Or are these always applied?

Also I'd really recommend to look into a solution that would add the description (and other info to generate the documentation) in the same place because it's going to be awful to manage multiple massive lists like this accurately.

@stevenbal
Copy link
Contributor Author

stevenbal commented Apr 18, 2024

It looks like this mixes regular settings with one-time configuration settings? Can we somehow split that in the code? Or are these always applied?

You mean DIGID_ENABLED right? I think I will split this one up to have a setting to enable the setup config for DigiD (SAML) and keep the old setting to enable DigiD in general (show the login button, etc)

With regards to the description/documentation, #1150 is probably the PR to tackle this in?

* add missing model fields to DigiD/eHerkenning OIDC admin form
* split up envvar into DIGID_ENABLED and DIGID_CONFIG_ENABLE
* use DIGID_ENABLED for both SAML and OIDC versions
Copy link
Contributor

@Bartvaderkin Bartvaderkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve it for now if we need it for this release, noting this overlaps with the other configuration tickets.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 98.34184% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 95.15%. Comparing base (a47782f) to head (957969e).
Report is 41 commits behind head on develop.

Files Patch % Lines
...urations/tests/bootstrap/test_setup_auth_config.py 97.82% 10 Missing ⚠️
src/open_inwoner/configurations/bootstrap/auth.py 98.78% 2 Missing ⚠️
src/open_inwoner/conf/base.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1137      +/-   ##
===========================================
+ Coverage    95.05%   95.15%   +0.09%     
===========================================
  Files          950      959       +9     
  Lines        33790    34753     +963     
===========================================
+ Hits         32119    33068     +949     
- Misses        1671     1685      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alextreme alextreme merged commit e82b6c3 into develop Apr 19, 2024
15 checks passed
@alextreme alextreme deleted the feature/2263-setup-config-auth branch April 19, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants