diff --git a/api/user/casdoor.go b/api/user/casdoor.go index 89a2f4c6..a018cb41 100644 --- a/api/user/casdoor.go +++ b/api/user/casdoor.go @@ -87,11 +87,16 @@ func CasdoorCallback(c *gin.Context) { } func GetCasdoorUri(c *gin.Context) { - endpoint := settings.CasdoorSettings.Endpoint clientId := settings.CasdoorSettings.ClientId redirectUri := settings.CasdoorSettings.RedirectUri state := settings.CasdoorSettings.Application + endpoint := settings.CasdoorSettings.Endpoint + // feature request #603 + if settings.CasdoorSettings.ExternalUrl != "" { + endpoint = settings.CasdoorSettings.ExternalUrl + } + if endpoint == "" || clientId == "" || redirectUri == "" || state == "" { c.JSON(http.StatusOK, gin.H{ "uri": "", diff --git a/docs/guide/config-casdoor.md b/docs/guide/config-casdoor.md index 0dac53c9..ac7a5fd1 100644 --- a/docs/guide/config-casdoor.md +++ b/docs/guide/config-casdoor.md @@ -9,6 +9,13 @@ By integrating Casdoor, Nginx UI can leverage these features to improve security This is the Endpoint of the Casdoor server. You need to make sure that Nginx UI can access this URL. +## ExternalUrl +- Type: `string` +- Version: `>= v2.0.0-beta.42` + +This is the external URL of the Casdoor server. It is used to generate the redirect URI. +If this option is not configured, the Endpoint will be used as the base URL for the redirect URI. + ## ClientId - Type: `string` diff --git a/docs/zh_CN/guide/config-casdoor.md b/docs/zh_CN/guide/config-casdoor.md index 4b6f1fb8..d8efffd3 100644 --- a/docs/zh_CN/guide/config-casdoor.md +++ b/docs/zh_CN/guide/config-casdoor.md @@ -8,6 +8,12 @@ Casdoor 是一个强大的、全面的身份认证解决方案,支持 OAuth 2. 这是 Casdoor 服务器的 URL。您需要确保 Nginx UI 可以访问此 URL。 +## ExternalUrl +- 类型:`string` +- 版本: `>= v2.0.0-beta.42` + +这是 Casdoor 服务器的外部 URL。它用于生成重定向 URI,在不配置次选项的情况下,将使用 Endpoint 作为重定向 URI 的基本 URL。 + ## ClientId - 类型:`string` diff --git a/docs/zh_TW/guide/config-casdoor.md b/docs/zh_TW/guide/config-casdoor.md index 56ba64ae..9fbe683b 100644 --- a/docs/zh_TW/guide/config-casdoor.md +++ b/docs/zh_TW/guide/config-casdoor.md @@ -8,6 +8,12 @@ Casdoor 是一個強大的、全面的身份認證解決方案,支持 OAuth 2. 這是 Casdoor 服務器的 URL。您需要確保 Nginx UI 可以訪問此 URL。 +## ExternalUrl +- 種類:`string` +- 版本: `>= v2.0.0-beta.42` + +這是 Casdoor 伺服器的外部 URL。它用於生成重定向 URI,在未配置此選項的情況下,將使用 Endpoint 作為重定向 URI 的基本 URL。 + ## ClientId - 類型:`string` diff --git a/settings/casdoor.go b/settings/casdoor.go index 4dc1054a..4840add7 100644 --- a/settings/casdoor.go +++ b/settings/casdoor.go @@ -2,6 +2,7 @@ package settings type Casdoor struct { Endpoint string `json:"endpoint" protected:"true"` + ExternalUrl string `json:"external_url" protected:"true"` ClientId string `json:"client_id" protected:"true"` ClientSecret string `json:"client_secret" protected:"true"` CertificatePath string `json:"certificate_path" protected:"true"` @@ -10,12 +11,4 @@ type Casdoor struct { RedirectUri string `json:"redirect_uri" protected:"true"` } -var CasdoorSettings = &Casdoor{ - Endpoint: "", - ClientId: "", - ClientSecret: "", - CertificatePath: "", - Organization: "", - Application: "", - RedirectUri: "", -} +var CasdoorSettings = &Casdoor{}