From 6021fc0f52ad7d2014734dcc5cda10c57da8fdcc Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 30 Jan 2022 22:29:34 +0100 Subject: [PATCH] providers/proxy: fix backend override persisting for other users Signed-off-by: Jens Langhammer --- internal/outpost/proxyv2/application/mode_proxy.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/outpost/proxyv2/application/mode_proxy.go b/internal/outpost/proxyv2/application/mode_proxy.go index 66a7569b1..746861dc5 100644 --- a/internal/outpost/proxyv2/application/mode_proxy.go +++ b/internal/outpost/proxyv2/application/mode_proxy.go @@ -71,18 +71,20 @@ func (a *Application) configureProxy() error { return nil } -func (a *Application) proxyModifyRequest(u *url.URL) func(req *http.Request) { +func (a *Application) proxyModifyRequest(ou *url.URL) func(req *http.Request) { return func(r *http.Request) { claims, _ := a.getClaims(r) if claims.Proxy.BackendOverride != "" { - var err error - u, err = url.Parse(claims.Proxy.BackendOverride) + u, err := url.Parse(claims.Proxy.BackendOverride) if err != nil { a.log.WithField("backend_override", claims.Proxy.BackendOverride).WithError(err).Warning("failed parse user backend override") } + r.URL.Scheme = u.Scheme + r.URL.Host = u.Host + } else { + r.URL.Scheme = ou.Scheme + r.URL.Host = ou.Host } - r.URL.Scheme = u.Scheme - r.URL.Host = u.Host } }