From fbc603876f9314e198046191738f7a2b175fbc85 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Tue, 17 Oct 2023 21:47:18 +0800 Subject: [PATCH] feat: add originFrontend to app.conf --- conf/app.conf | 1 + object/oidc_discovery.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/conf/app.conf b/conf/app.conf index 39beb433..13e8061e 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -16,6 +16,7 @@ verificationCodeTimeout = 10 initScore = 0 logPostOnly = true origin = +originFrontend = staticBaseUrl = "https://cdn.casbin.org" isDemoMode = false batchSize = 100 diff --git a/object/oidc_discovery.go b/object/oidc_discovery.go index 41224111..22b5e9eb 100644 --- a/object/oidc_discovery.go +++ b/object/oidc_discovery.go @@ -59,7 +59,7 @@ func isIpAddress(host string) bool { return ip != nil } -func getOriginFromHost(host string) (string, string) { +func getOriginFromHostInternal(host string) (string, string) { origin := conf.GetConfigString("origin") if origin != "" { return origin, origin @@ -82,6 +82,17 @@ func getOriginFromHost(host string) (string, string) { } } +func getOriginFromHost(host string) (string, string) { + originF, originB := getOriginFromHostInternal(host) + + originFrontend := conf.GetConfigString("originFrontend") + if originFrontend != "" { + originF = originFrontend + } + + return originF, originB +} + func GetOidcDiscovery(host string) OidcDiscovery { originFrontend, originBackend := getOriginFromHost(host)