git.iko.soy/typeable/oauth2-proxy
on master help sign in
Use OAuthProxy.GetRedirect in /sign_in, honoring the 'rd' query parameter (#405)

* Use OAuthProxy.GetRedirect in /sign_in, honoring the 'rd' query parameter * CHANGELOG.md - Add a changelog entry for #405

commit907de4e14174497861c850f10fd9e5139c9f29cd authorTimo Beckers <ti-mo@users.noreply.github.com> dateFri 28 Feb 2020, 10:59 (7 years ago) parent4f553bc
2 files changed+11−7
CHANGELOG.md+2−1 oauthproxy.go+9−6
CHANGELOG.md+2−1
@@ -3,7 +3,7 @@
33## Release Hightlights
44
55## Important Notes
6−- [#335] The session expiry for the OIDC provider is now taken from the Token Response (expires_in) rather than from the id_token (exp)
6+- [#335] The session expiry for the OIDC provider is now taken from the Token Response (expires_in) rather than from the id_token (exp)
77
88## Breaking Changes
99
@@ -16,6 +16,7 @@
1616- [#363](https://github.com/pusher/oauth2_proxy/pull/363) Extension of Redis Session Store to Support Redis Cluster (@yan-dblinf)
1717- [#353](https://github.com/pusher/oauth2_proxy/pull/353) Fix login page fragment handling after soft reload on Firefox (@ffdybuster)
1818- [#355](https://github.com/pusher/oauth2_proxy/pull/355) Add Client Secret File support for providers that rotate client secret via file system (@pasha-r)
19+- [#405](https://github.com/pusher/oauth2_proxy/pull/405) The `/sign_in` page now honors the `rd` query parameter, fixing the redirect after a successful authentication (@ti-mo)
1920
2021# v5.0.0
2122
oauthproxy.go+9−6
@@ -446,12 +446,15 @@ func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
446446 p.ClearSessionCookie(rw, req)
447447 rw.WriteHeader(code)
448448
449− redirecURL := req.URL.RequestURI()
450− if req.Header.Get("X-Auth-Request-Redirect") != "" {
451− redirecURL = req.Header.Get("X-Auth-Request-Redirect")
449+ redirectURL, err := p.GetRedirect(req)
450+ if err != nil {
451+ logger.Printf("Error obtaining redirect: %s", err.Error())
452+ p.ErrorPage(rw, 500, "Internal Error", err.Error())
453+ return
452454 }
453− if redirecURL == p.SignInPath {
454− redirecURL = "/"
455+
456+ if redirectURL == p.SignInPath {
457+ redirectURL = "/"
455458 }
456459
457460 t := struct {
@@ -466,7 +469,7 @@ func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
466469 ProviderName: p.provider.Data().ProviderName,
467470 SignInMessage: p.SignInMessage,
468471 CustomLogin: p.displayCustomLoginForm(),
469− Redirect: redirecURL,
472+ Redirect: redirectURL,
470473 Version: VERSION,
471474 ProxyPrefix: p.ProxyPrefix,
472475 Footer: template.HTML(p.Footer),