-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ [#4246] Refactor digig-eherkenning-oidc-generics auth request flow
Simplified the entire authentication request flow where the user gets redirect to the relevant identity provider. There is now a single 'view' implementation that takes a config class/model to use which can be used to directly obtain the redirect target instead of having to go through multiple redirects on our own URLs. The view takes care of input sanitation and managing the authentication state. This substantially cleans up the inheritance/mixin chains for the OIDC flows and makes the code easier to follow.
- Loading branch information
1 parent
b8901c4
commit 60f7404
Showing
3 changed files
with
159 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class OIDCProviderOutage(Exception): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Any | ||
|
||
from mozilla_django_oidc.utils import import_from_settings | ||
|
||
from .models import OpenIDConnectBaseConfig | ||
|
||
|
||
def get_setting_from_config(config: OpenIDConnectBaseConfig, attr: str, *args) -> Any: | ||
""" | ||
Look up a setting from the config record or fall back to Django settings. | ||
TODO: port this into mozilla_django_oidc_db. | ||
""" | ||
attr_lowercase = attr.lower() | ||
if hasattr(config, attr_lowercase): | ||
# Workaround for OIDC_RP_IDP_SIGN_KEY being an empty string by default. | ||
# mozilla-django-oidc explicitly checks if `OIDC_RP_IDP_SIGN_KEY` is not `None` | ||
# https://github.com/mozilla/mozilla-django-oidc/blob/master/mozilla_django_oidc/auth.py#L189 | ||
if (value_from_config := getattr(config, attr_lowercase)) == "": | ||
return None | ||
return value_from_config | ||
return import_from_settings(attr, *args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters