diff --git a/ChangeLog.rst b/ChangeLog.rst index c81fd7e56a..fa68267d22 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,3 +1,16 @@ +0.60.0 (unreleased) +******************* + +Backwards incompatible changes +------------------------------ + +- You can now specify the URL path prefix that is used for all OpenID Connect + providers using ``SOCIALACCOUNT_OPENID_CONNECT_URL_PREFIX``. By default, it is + set to ``"oidc"``, meaning, an OpenID Connect provider with provider ID + ``foo`` uses ``/accounts/oidc/foo/login/`` as its login URL. Set it to empty + (``""``) to keep the previous URL structure (``/accounts/foo/login/``). + + 0.59.0 (2023-12-13) ******************* diff --git a/allauth/socialaccount/app_settings.py b/allauth/socialaccount/app_settings.py index 40c6b2e8b7..f613ae67be 100644 --- a/allauth/socialaccount/app_settings.py +++ b/allauth/socialaccount/app_settings.py @@ -143,6 +143,10 @@ def SOCIALACCOUNT_STR(self): def REQUESTS_TIMEOUT(self): return self._setting("REQUESTS_TIMEOUT", 5) + @property + def OPENID_CONNECT_URL_PREFIX(self): + return self._setting("OPENID_CONNECT_URL_PREFIX", "oidc") + _app_settings = AppSettings("SOCIALACCOUNT_") diff --git a/allauth/socialaccount/providers/openid_connect/urls.py b/allauth/socialaccount/providers/openid_connect/urls.py index 458f855e86..d86984a0a3 100644 --- a/allauth/socialaccount/providers/openid_connect/urls.py +++ b/allauth/socialaccount/providers/openid_connect/urls.py @@ -1,5 +1,7 @@ from django.urls import include, path, re_path +from allauth.socialaccount import app_settings + from . import views @@ -22,3 +24,8 @@ ), ) ] + +if app_settings.OPENID_CONNECT_URL_PREFIX: + urlpatterns = [ + path(f"{app_settings.OPENID_CONNECT_URL_PREFIX}/", include(urlpatterns)) + ] diff --git a/allauth/urls.py b/allauth/urls.py index c4b4e6aa4b..adcab31151 100644 --- a/allauth/urls.py +++ b/allauth/urls.py @@ -23,6 +23,8 @@ # We need to move the OpenID Connect provider to the end. The reason is that # matches URLs that the builtin providers also match. +# +# NOTE: Only needed if OPENID_CONNECT_URL_PREFIX is blank. provider_classes = [cls for cls in provider_classes if cls.id != "openid_connect"] + [ cls for cls in provider_classes if cls.id == "openid_connect" ] diff --git a/docs/socialaccount/configuration.rst b/docs/socialaccount/configuration.rst index bb75faa412..da9e06e01c 100644 --- a/docs/socialaccount/configuration.rst +++ b/docs/socialaccount/configuration.rst @@ -84,3 +84,8 @@ Available settings: ``SOCIALACCOUNT_STORE_TOKENS`` (default: ``False``) Indicates whether or not the access tokens are stored in the database. + +``SOCIALACCOUNT_OPENID_CONNECT_URL_PREFIX`` (default: ``"oidc"``) + The URL path prefix that is used for all OpenID Connect providers. By default, + it is set to ``"oidc"``, meaning, an OpenID Connect provider with provider ID + ``foo`` uses ``/accounts/oidc/foo/login/`` as its login URL.