From d5e66d39944fe26a0da36861722d17282b21d8da Mon Sep 17 00:00:00 2001 From: zdebel Date: Thu, 31 Oct 2024 15:03:35 +0100 Subject: [PATCH] Fix oauth endpoint to support detecting https in 'Forwarded' header, enabling google support (#359) --- internal/web/auth.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/web/auth.go b/internal/web/auth.go index c33b8d7..aa8bfff 100644 --- a/internal/web/auth.go +++ b/internal/web/auth.go @@ -315,6 +315,20 @@ func oauth(ctx echo.Context) error { httpProtocol = "https" } + forwarded_hdr := ctx.Request().Header.Get("Forwarded") + if forwarded_hdr != "" { + fields := strings.Split(forwarded_hdr, ";") + fwd := make(map[string]string) + for _, v := range fields { + p := strings.Split(v, "=") + fwd[p[0]] = p[1] + } + val, ok := fwd["proto"] + if ok && val == "https" { + httpProtocol = "https" + } + } + var opengistUrl string if config.C.ExternalUrl != "" { opengistUrl = config.C.ExternalUrl