Skip to content

Commit

Permalink
🐛 [#4435] Exempt legacy OIDC URLs from sessionrefresh
Browse files Browse the repository at this point in the history
by default, the OIDC endpoints that are used are marked as exempt from SessionRefresh, but this caused infinite redirects in case the legacy URLs were used
  • Loading branch information
stevenbal committed Jul 1, 2024
1 parent a9c4f11 commit 7a59b7d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/openforms/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
"openforms.translations.middleware.AdminLocaleMiddleware",
"hijack.middleware.HijackUserMiddleware",
"openforms.middleware.SessionTimeoutMiddleware",
"mozilla_django_oidc_db.middleware.SessionRefresh",
"openforms.utils.middleware.SessionRefresh",
"maykin_2fa.middleware.OTPMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
Expand Down
26 changes: 26 additions & 0 deletions src/openforms/utils/middleware.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from django.urls import reverse
from django.utils.functional import cached_property

from mozilla_django_oidc_db.middleware import SessionRefresh as _SessionRefresh

from openforms.config.models import CSPSetting


Expand Down Expand Up @@ -60,3 +65,24 @@ def _append_dict_list_values(target, source):
target[k] = [v]
else:
target[k] = list(set(v))


class SessionRefresh(_SessionRefresh):

@cached_property
def exempt_urls(self):
"""
Issue: https://github.com/open-formulieren/open-forms/issues/4435
Make sure the legacy OIDC URLs are also exempt from session refresh to avoid
infinite redirects
"""
extra = {
reverse(name)
for name in [
"legacy_oidc:oidc_authentication_init",
"legacy_oidc:oidc_authentication_callback",
"legacy_oidc:oidc_logout",
]
}
return super().exempt_urls | extra

0 comments on commit 7a59b7d

Please sign in to comment.