From 90a22b2f39a31af37c8d8e7f7c47f475e0d70933 Mon Sep 17 00:00:00 2001 From: Sjoerd Mulder Date: Wed, 16 Nov 2016 12:06:18 +0530 Subject: [PATCH] Use X-Auth-Request-Redirect request header in sign-in page This is useful in Nginx auth_request mode, if a 401 handler is configured to redirect to the sign-in page. As the request URL does not reflect the actual URL, the value is taken from the header "X-Auth-Request-Redirect" instead. Based on #247 --- oauthproxy.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oauthproxy.go b/oauthproxy.go index 5cf9b44..f4cd577 100644 --- a/oauthproxy.go +++ b/oauthproxy.go @@ -363,6 +363,9 @@ func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code rw.WriteHeader(code) redirect_url := req.URL.RequestURI() + if req.Header.Get("X-Auth-Request-Redirect") != "" { + redirect_url = req.Header.Get("X-Auth-Request-Redirect") + } if redirect_url == p.SignInPath { redirect_url = "/" }