Skip to content

Commit

Permalink
feat(socialaccount): OPENID_CONNECT_URL_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Dec 13, 2023
1 parent ce1658c commit e786d10
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -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)
*******************

Expand Down
4 changes: 4 additions & 0 deletions allauth/socialaccount/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_")

Expand Down
7 changes: 7 additions & 0 deletions allauth/socialaccount/providers/openid_connect/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.urls import include, path, re_path

from allauth.socialaccount import app_settings

from . import views


Expand All @@ -22,3 +24,8 @@
),
)
]

if app_settings.OPENID_CONNECT_URL_PREFIX:
urlpatterns = [
path(f"{app_settings.OPENID_CONNECT_URL_PREFIX}/", include(urlpatterns))
]
2 changes: 2 additions & 0 deletions allauth/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
5 changes: 5 additions & 0 deletions docs/socialaccount/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit e786d10

Please sign in to comment.