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 dc87da4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/openforms/accounts/middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.urls import reverse
from django.utils.functional import cached_property

from mozilla_django_oidc_db.middleware import SessionRefresh as _SessionRefresh


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
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.accounts.middleware.SessionRefresh",
"maykin_2fa.middleware.OTPMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
Expand Down

0 comments on commit dc87da4

Please sign in to comment.