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

✨ [#1902/1903] DigiD/eHerkenning via OIDC #879

Merged
merged 9 commits into from
Dec 12, 2023

Conversation

stevenbal
Copy link
Contributor

@stevenbal stevenbal commented Dec 4, 2023

tasks:

Issues:

  • log-outgoing-requests fails on logout due to the URL being longer than 1000 chars (django.db.utils.DataError: value too long for type character varying(1000)). We should probably truncate chars past 1000 in the library? -> already fixed in [#29] change url field to textfield django-log-outgoing-requests#30 as Paul remarked
  • do we want to use any data - other than BSN - from the payload we get back via OIDC? or do we leave this to the signal that fetches data from HaalCentraal?
  • Multiple feature flags seems annoying, to enable OIDC eHerkenning you have to enable eHerkenning via siteconfig and via OIDC config (as override), not sure how we can improve this

@stevenbal stevenbal marked this pull request as draft December 4, 2023 15:54
@stevenbal stevenbal changed the title ⬆️ [#1902] Bump mozilla-django-oidc-db to 0.12.0 ✨ [#1902/1903] DigiD/eHerkenning via OIDC Dec 5, 2023
@stevenbal stevenbal force-pushed the feature/1902-digid-oidc branch 2 times, most recently from 575ac6e to b1fcb69 Compare December 5, 2023 12:57
@stevenbal stevenbal force-pushed the feature/1902-digid-oidc branch 2 times, most recently from c165770 to 37cbef8 Compare December 5, 2023 15:31
@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (345147d) 92.81% compared to head (6a019ca) 92.91%.
Report is 10 commits behind head on develop.

Files Patch % Lines
src/digid_eherkenning_oidc_generics/views.py 89.79% 5 Missing ⚠️
src/open_inwoner/accounts/views/registration.py 78.57% 3 Missing ⚠️
src/digid_eherkenning_oidc_generics/backends.py 97.05% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #879      +/-   ##
===========================================
+ Coverage    92.81%   92.91%   +0.10%     
===========================================
  Files          802      815      +13     
  Lines        27516    28001     +485     
===========================================
+ Hits         25538    26017     +479     
- Misses        1978     1984       +6     

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

@stevenbal stevenbal marked this pull request as ready for review December 5, 2023 16:08
@alextreme
Copy link
Member

Interesting approach, adding keycloak to the docker setup and as a (possible) CI step would offer a nice integrationtest for OIDC.

Ensure that you check that cancelling the loginflow also works as expected. This currently isn't working properly for Open Formulieren in combination with OIDC+DigiD, but showing a proper 'cancellation' message is a mandatory part of a DigiD audit.

log-outgoing-requests fails on logout due to the URL being longer than 1000 chars (django.db.utils.DataError: value too long for type character varying(1000)). We should probably truncate chars past 1000 in the library?

Please do (or at least create an issue for it). This sounds like a bit of a timebomb if you ran into it using OIDC, it is our own library but haven't seen this cause problems before.

do we want to use any data - other than BSN - from the payload we get back via OIDC? or do we leave this to the signal that fetches data from HaalCentraal?

We don't need anything other than the BSN if HaalCentraal BRP is connected, but I suspect that we can use the claim mapping if that's not the case? Either way the default claim mapping can be empty.

Multiple feature flags seems annoying, to enable OIDC eHerkenning you have to enable eHerkenning via siteconfig and via OIDC config (as override), not sure how we can improve this

I'm open to suggestions and further improvements. Maybe turn it the other way around, that we configure it via the siteconfig (DigiD: disabled, mock, Logius/SAML, OIDC) and that configuring this in turn toggles the SAML/OIDC config on? Maybe @pi-sigma has suggestions too.

@pi-sigma
Copy link
Contributor

pi-sigma commented Dec 7, 2023

@stevenbal The url max length issue has been reported and (should be) fixed by converting the url field to a TextField: maykinmedia/django-log-outgoing-requests#29

docker/keycloak/README.md Outdated Show resolved Hide resolved
src/digid_eherkenning_oidc_generics/backends.py Outdated Show resolved Hide resolved
return user

def update_user(self, user, claims):
# TODO should we do anything here? or do we only fetch data from HaalCentraal
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try to resolve this question (discuss with @alextreme) so it doesn't remain here.

src/open_inwoner/accounts/tests/test_oidc_views.py Outdated Show resolved Hide resolved
src/open_inwoner/accounts/tests/test_oidc_views.py Outdated Show resolved Hide resolved
src/open_inwoner/accounts/tests/test_oidc_views.py Outdated Show resolved Hide resolved
src/open_inwoner/accounts/tests/test_oidc_views.py Outdated Show resolved Hide resolved
src/open_inwoner/accounts/views/registration.py Outdated Show resolved Hide resolved
@pi-sigma
Copy link
Contributor

pi-sigma commented Dec 7, 2023

@stevenbal The two-step approach to configuring eHerkenning with OIDC/SAML may not be ideal, but enabling all of it in siteconfig has its own issues. The most straightforward approach IMHO would be to keep the two-step approach, but document the OIDC/SAML config options in the eHerkenning help text in siteconfig. Perhaps even include a link to Koppelingen > eHerkenning/eIDAS-configuratie and Koppelingen > OpenID Connect configuration (btw: why is the latter English? I thought client-facing text should be Dutch by default. Not pressing as it will be translated anyway).

@stevenbal
Copy link
Contributor Author

Ensure that you check that cancelling the loginflow also works as expected. This currently isn't working properly for Open Formulieren in combination with OIDC+DigiD, but showing a proper 'cancellation' message is a mandatory part of a DigiD audit.

@alextreme I'm not sure how to test this locally without actually connecting to a DigiD test/preprod instance (via Keycloak). Keycloak itself doesn't provide a cancel button that I could test with, should returning to the previous page also lead to this cancellation message?

@alextreme
Copy link
Member

Ensure that you check that cancelling the loginflow also works as expected. This currently isn't working properly for Open Formulieren in combination with OIDC+DigiD, but showing a proper 'cancellation' message is a mandatory part of a DigiD audit.

@alextreme I'm not sure how to test this locally without actually connecting to a DigiD test/preprod instance (via Keycloak). Keycloak itself doesn't provide a cancel button that I could test with, should returning to the previous page also lead to this cancellation message?

In that case create a task to verify this after the next release on acc.

@stevenbal stevenbal marked this pull request as draft December 7, 2023 11:15
@stevenbal
Copy link
Contributor Author

We don't need anything other than the BSN if HaalCentraal BRP is connected, but I suspect that we can use the claim mapping if that's not the case? Either way the default claim mapping can be empty.

The singletonmodels for DigD and eHerkenning OIDC don't have claim mappings (copied them from openforms), so currently all that is taken from the payload is BSN/KVK

tasks:
* https://taiga.maykinmedia.nl/project/open-inwoner/task/1902
* https://taiga.maykinmedia.nl/project/open-inwoner/task/1903

To avoid the OIDC backends for other variants attempting to authenticate a user for another variant, we check if the callback path matches or not
@stevenbal
Copy link
Contributor Author

@alextreme @pi-sigma with regards to the feature flags, I updated the helptext for eherkenning_enabled in SiteConfiguration and the enabled attributes on the OIDCConfig, to explain that enabling OIDC overrides the use of SAML

@alextreme
Copy link
Member

We don't need anything other than the BSN if HaalCentraal BRP is connected, but I suspect that we can use the claim mapping if that's not the case? Either way the default claim mapping can be empty.

The singletonmodels for DigD and eHerkenning OIDC don't have claim mappings (copied them from openforms), so currently all that is taken from the payload is BSN/KVK

Ah you are correct. As long as there is a 'Claimnaam BSN' that can be modified, it normally should be bsn but I've noticed that different OIDC brokers pass along this value in a different attribute.

@stevenbal
Copy link
Contributor Author

Ah you are correct. As long as there is a 'Claimnaam BSN' that can be modified, it normally should be bsn but I've noticed that different OIDC brokers pass along this value in a different attribute.

This indeed configurable via the admin:

image

and for eHerkenning

image

@stevenbal stevenbal marked this pull request as ready for review December 11, 2023 10:05
@alextreme alextreme merged commit ecf711d into develop Dec 12, 2023
16 checks passed
@alextreme alextreme deleted the feature/1902-digid-oidc branch December 12, 2023 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants