From 1437b10252f29ec1f37dc443e7d3355c3e24d6a0 Mon Sep 17 00:00:00 2001 From: voc0der Date: Wed, 29 Jan 2025 13:10:38 -0500 Subject: [PATCH] Feature: Allow custom redirect_uri for OIDC --- docs/configuration.md | 6 ++++++ src/paperless/adapter.py | 3 +-- src/paperless/settings.py | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 799620c05..28496576d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -581,6 +581,12 @@ system. See the corresponding Defaults to 'https' +#### [`PAPERLESS_OIDC_REDIRECT_URI=`](#PAPERLESS_OIDC_REDIRECT_URI) {#PAPERLESS_OIDC_REDIRECT_URI} + +: The redirect URI which will be passed to the OAuth callback. + + : Defaults to ''. + #### [`PAPERLESS_ACCOUNT_EMAIL_VERIFICATION=`](#PAPERLESS_ACCOUNT_EMAIL_VERIFICATION) {#PAPERLESS_ACCOUNT_EMAIL_VERIFICATION} : Determines whether email addresses are verified during signup (as performed by Django allauth). See the relevant diff --git a/src/paperless/adapter.py b/src/paperless/adapter.py index add2bf45d..c29a2d3d4 100644 --- a/src/paperless/adapter.py +++ b/src/paperless/adapter.py @@ -77,8 +77,7 @@ class CustomSocialAccountAdapter(DefaultSocialAccountAdapter): Returns the default URL to redirect to after successfully connecting a social account. """ - url = reverse("base") - return url + return getattr(settings, 'OIDC_REDIRECT_URI', '') or reverse("base") def populate_user(self, request, sociallogin, data): """ diff --git a/src/paperless/settings.py b/src/paperless/settings.py index a817abd70..16d608ce8 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -457,6 +457,8 @@ ACCOUNT_DEFAULT_HTTP_PROTOCOL = os.getenv( "https", ) +OIDC_REDIRECT_URI: Final[str] = os.getenv("PAPERLESS_OIDC_REDIRECT_URI", "") + ACCOUNT_ADAPTER = "paperless.adapter.CustomAccountAdapter" ACCOUNT_ALLOW_SIGNUPS = __get_boolean("PAPERLESS_ACCOUNT_ALLOW_SIGNUPS")