Skip to content

Commit

Permalink
⚰️ [#4246] Remove code obsoleted by the refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed May 3, 2024
1 parent 10185e9 commit 11ce754
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

from mozilla_django_oidc.urls import urlpatterns

from .views import (
DigiDMachtigenOIDCAuthenticationCallbackView,
DigiDMachtigenOIDCAuthenticationRequestView,
)
from .views import DigiDMachtigenOIDCAuthenticationCallbackView

app_name = "digid_machtigen_oidc"

Expand All @@ -16,9 +13,4 @@
DigiDMachtigenOIDCAuthenticationCallbackView.as_view(),
name="callback",
),
path(
"authenticate/",
DigiDMachtigenOIDCAuthenticationRequestView.as_view(),
name="init",
),
] + urlpatterns
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

from mozilla_django_oidc.urls import urlpatterns

from .views import (
DigiDOIDCAuthenticationCallbackView,
DigiDOIDCAuthenticationRequestView,
)
from .views import DigiDOIDCAuthenticationCallbackView

app_name = "digid_oidc"

Expand All @@ -16,9 +13,4 @@
DigiDOIDCAuthenticationCallbackView.as_view(),
name="callback",
),
path(
"authenticate/",
DigiDOIDCAuthenticationRequestView.as_view(),
name="init",
),
] + urlpatterns
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

from mozilla_django_oidc.urls import urlpatterns

from .views import (
EHerkenningBewindvoeringOIDCAuthenticationCallbackView,
EHerkenningBewindvoeringOIDCAuthenticationRequestView,
)
from .views import EHerkenningBewindvoeringOIDCAuthenticationCallbackView

app_name = "eherkenning_bewindvoering_oidc"

Expand All @@ -16,9 +13,4 @@
EHerkenningBewindvoeringOIDCAuthenticationCallbackView.as_view(),
name="callback",
),
path(
"authenticate/",
EHerkenningBewindvoeringOIDCAuthenticationRequestView.as_view(),
name="init",
),
] + urlpatterns
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

from mozilla_django_oidc.urls import urlpatterns

from .views import (
eHerkenningOIDCAuthenticationCallbackView,
eHerkenningOIDCAuthenticationRequestView,
)
from .views import eHerkenningOIDCAuthenticationCallbackView

app_name = "eherkenning_oidc"

Expand All @@ -16,9 +13,4 @@
eHerkenningOIDCAuthenticationCallbackView.as_view(),
name="callback",
),
path(
"authenticate/",
eHerkenningOIDCAuthenticationRequestView.as_view(),
name="init",
),
] + urlpatterns
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import logging

from django.core.exceptions import DisallowedRedirect
from django.http import HttpResponseRedirect

import requests
from furl import furl
from mozilla_django_oidc.views import get_next_url

from digid_eherkenning_oidc_generics.mixins import (
SoloConfigDigiDMachtigenMixin,
Expand All @@ -15,7 +10,6 @@
)
from digid_eherkenning_oidc_generics.views import (
OIDCAuthenticationCallbackView as _OIDCAuthenticationCallbackView,
OIDCAuthenticationRequestView as _OIDCAuthenticationRequestView,
)
from openforms.authentication.contrib.digid.views import (
DIGID_MESSAGE_PARAMETER,
Expand All @@ -34,41 +28,6 @@
logger = logging.getLogger(__name__)


class OIDCAuthenticationRequestView(_OIDCAuthenticationRequestView):
plugin_identifier = ""

def get(self, request):
redirect_field_name = self.get_settings("OIDC_REDIRECT_FIELD_NAME", "next")
next_url = get_next_url(request, redirect_field_name)
if not next_url:
raise DisallowedRedirect

# We add our own key to keep track of the redirect URL. In the case of authentication failure (or canceled logins),
# the session is cleared, so in OIDCAuthenticationCallbackView we store this URL so that we know where to.
self.request.session["of_redirect_next"] = next_url

try:
# Verify that the identity provider endpoint can be reached
response = requests.get(self.OIDC_OP_AUTH_ENDPOINT)
if response.status_code > 400:
response.raise_for_status()
except Exception as e:
logger.exception(
"authentication exception during 'start_login()' of plugin '%(plugin_id)s'",
{"plugin_id": self.plugin_identifier},
exc_info=e,
)
# append failure parameter and return to form
f = furl(next_url)
failure_url = f.args["next"]

f = furl(failure_url)
f.args[BACKEND_OUTAGE_RESPONSE_PARAMETER] = self.plugin_identifier
return HttpResponseRedirect(f.url)

return super().get(request)


class OIDCAuthenticationCallbackView(_OIDCAuthenticationCallbackView):
def get(self, request):
self._redirect_next = request.session.get("of_redirect_next")
Expand Down Expand Up @@ -102,12 +61,6 @@ def failure_url(self):
return f.url


class DigiDOIDCAuthenticationRequestView(
SoloConfigDigiDMixin, OIDCAuthenticationRequestView
):
plugin_identifier = "digid_oidc"


class DigiDOIDCAuthenticationCallbackView(
SoloConfigDigiDMixin, OIDCAuthenticationCallbackView
):
Expand All @@ -123,12 +76,6 @@ def get_error_message_parameters(
return (BACKEND_OUTAGE_RESPONSE_PARAMETER, self.plugin_identifier)


class eHerkenningOIDCAuthenticationRequestView(
SoloConfigEHerkenningMixin, OIDCAuthenticationRequestView
):
plugin_identifier = "eherkenning_oidc"


class eHerkenningOIDCAuthenticationCallbackView(
SoloConfigEHerkenningMixin, OIDCAuthenticationCallbackView
):
Expand All @@ -147,12 +94,6 @@ def get_error_message_parameters(
return (BACKEND_OUTAGE_RESPONSE_PARAMETER, self.plugin_identifier)


class DigiDMachtigenOIDCAuthenticationRequestView(
SoloConfigDigiDMachtigenMixin, OIDCAuthenticationRequestView
):
plugin_identifier = "digid_machtigen_oidc"


class DigiDMachtigenOIDCAuthenticationCallbackView(
SoloConfigDigiDMachtigenMixin, OIDCAuthenticationCallbackView
):
Expand All @@ -168,12 +109,6 @@ def get_error_message_parameters(
return (BACKEND_OUTAGE_RESPONSE_PARAMETER, self.plugin_identifier)


class EHerkenningBewindvoeringOIDCAuthenticationRequestView(
SoloConfigEHerkenningBewindvoeringMixin, OIDCAuthenticationRequestView
):
plugin_identifier = "eherkenning_bewindvoering_oidc"


class EHerkenningBewindvoeringOIDCAuthenticationCallbackView(
SoloConfigEHerkenningBewindvoeringMixin, OIDCAuthenticationCallbackView
):
Expand Down

0 comments on commit 11ce754

Please sign in to comment.