proxy/forward_auth: copy response headers as request headers (#1577)

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
bobby 2020-11-05 09:31:01 -08:00 committed by GitHub
parent ccdd1e5586
commit d1bab414c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,6 +103,13 @@ func (p *Proxy) allowUpstream(w http.ResponseWriter, r *http.Request) error {
if status := r.FormValue("auth_status"); status == fmt.Sprint(http.StatusForbidden) {
return httputil.NewError(http.StatusForbidden, errors.New(http.StatusText(http.StatusForbidden)))
}
// in forward-auth configuration we want to treat our request headers as response headers
// so that they can be forwarded by the fronting proxy, if desired
for k, vs := range r.Header {
for _, v := range vs {
w.Header().Set(k, v)
}
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("X-Content-Type-Options", "nosniff")
w.WriteHeader(http.StatusOK)