git.iko.soy/typeable/oauth2-proxy
on master help sign in
More fully support X-Auth-Request-Redirect header

Docs showed that the X-Auth-Request-Redirect header can specify a redirect URI, but only the rd POST parameter was being honored This fixes that.

commita209a52df1e8462796918392308a56f5b5d959ff authorIan Hunter <ian@ianhunter.me> dateSat 17 Aug 2019, 15:50 (7 years ago) parentd00c14a
2 files changed+6−1
docs/configuration/configuration.md+2 oauthproxy.go+4−1
docs/configuration/configuration.md+2
@@ -247,6 +247,8 @@ server {
247247 proxy_set_header X-Real-IP $remote_addr;
248248 proxy_set_header X-Scheme $scheme;
249249 proxy_set_header X-Auth-Request-Redirect $request_uri;
250+ # or, if you are handling multiple domains:
251+ # proxy_set_header X-Auth-Request-Redirect $scheme://$host$request_uri;
250252 }
251253 location = /oauth2/auth {
252254 proxy_pass http://127.0.0.1:4180;
oauthproxy.go+4−1
@@ -480,7 +480,10 @@ func (p *OAuthProxy) GetRedirect(req *http.Request) (redirect string, err error)
480480 return
481481 }
482482
483− redirect = req.Form.Get("rd")
483+ redirect = req.Header.Get("X-Auth-Request-Redirect")
484+ if req.Form.Get("rd") != "" {
485+ redirect = req.Form.Get("rd")
486+ }
484487 if !p.IsValidRedirect(redirect) {
485488 redirect = req.URL.Path
486489 if strings.HasPrefix(redirect, p.ProxyPrefix) {