From fed9332246ffe81d05c79969182c0042139b65ae Mon Sep 17 00:00:00 2001 From: People257 <120806858+People257@users.noreply.github.com> Date: Fri, 23 May 2025 17:23:34 +0800 Subject: [PATCH] feat: can configure Domain field in Nextcloud OAuth provider (#3813) --- idp/goth.go | 13 ++++++++++--- web/src/ProviderEditPage.js | 2 +- web/src/auth/Provider.js | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/idp/goth.go b/idp/goth.go index 8affe072..531072fa 100644 --- a/idp/goth.go +++ b/idp/goth.go @@ -278,9 +278,16 @@ func NewGothIdProvider(providerType string, clientId string, clientSecret string Session: &naver.Session{}, } case "Nextcloud": - idp = GothIdProvider{ - Provider: nextcloud.New(clientId, clientSecret, redirectUrl), - Session: &nextcloud.Session{}, + if hostUrl != "" { + idp = GothIdProvider{ + Provider: nextcloud.NewCustomisedDNS(clientId, clientSecret, redirectUrl, hostUrl), + Session: &nextcloud.Session{}, + } + } else { + idp = GothIdProvider{ + Provider: nextcloud.New(clientId, clientSecret, redirectUrl), + Session: &nextcloud.Session{}, + } } case "OneDrive": idp = GothIdProvider{ diff --git a/web/src/ProviderEditPage.js b/web/src/ProviderEditPage.js index 9eb94396..5a320a45 100644 --- a/web/src/ProviderEditPage.js +++ b/web/src/ProviderEditPage.js @@ -950,7 +950,7 @@ class ProviderEditPage extends React.Component { ) } { - this.state.provider.type !== "ADFS" && this.state.provider.type !== "AzureAD" && this.state.provider.type !== "AzureADB2C" && (this.state.provider.type !== "Casdoor" && this.state.category !== "Storage") && this.state.provider.type !== "Okta" ? null : ( + this.state.provider.type !== "ADFS" && this.state.provider.type !== "AzureAD" && this.state.provider.type !== "AzureADB2C" && (this.state.provider.type !== "Casdoor" && this.state.category !== "Storage") && this.state.provider.type !== "Okta" && this.state.provider.type !== "Nextcloud" ? null : ( {Setting.getLabel(i18next.t("provider:Domain"), i18next.t("provider:Domain - Tooltip"))} : diff --git a/web/src/auth/Provider.js b/web/src/auth/Provider.js index 2f1c83a4..6d754d21 100644 --- a/web/src/auth/Provider.js +++ b/web/src/auth/Provider.js @@ -402,6 +402,10 @@ export function getAuthUrl(application, provider, method, code) { redirectUri = `${redirectOrigin}/api/callback`; } else if (provider.type === "Google" && provider.disableSsl) { scope += "+https://www.googleapis.com/auth/user.phonenumbers.read"; + } else if (provider.type === "Nextcloud") { + if (provider.domain) { + endpoint = `${provider.domain}/apps/oauth2/authorize`; + } } if (provider.type === "Google" || provider.type === "GitHub" || provider.type === "Facebook"