From 544ba3bd7dfe74e105bc0c004a6f494f56f92cb4 Mon Sep 17 00:00:00 2001 From: Matthew Hughes Date: Tue, 16 Mar 2021 14:07:00 -0500 Subject: [PATCH] copy url and method if desired --- backends/upstream/auth.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backends/upstream/auth.go b/backends/upstream/auth.go index d873088..79a105f 100644 --- a/backends/upstream/auth.go +++ b/backends/upstream/auth.go @@ -51,6 +51,8 @@ type Upstream struct { InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"` FollowRedirects bool `json:"follow_redirects,omitempty"` PassCookies bool `json:"pass_cookies,omitempty"` + PassTargetURL bool `json:"pass_target_url,omitempty"` + PassMethod bool `json:"pass_method,omitempty"` Match *jsontypes.Regexp `json:"match,omitempty"` Forward struct { @@ -117,6 +119,14 @@ func (h Upstream) Authenticate(r *http.Request) (string, error) { h.copyRequest(r, req) + if h.passTargetURL { + req.Header.Add("X-Auth-URL", r.RequestURI) + } + + if h.passMethod { + req.Header.Add("X-Auth-Method", r.Method) + } + resp, err := c.Do(req) if err != nil { return "", err