@@ -236,6 +236,22 @@ func (p *OauthProxy) ManualSignIn(rw http.ResponseWriter, req *http.Request) (st
236 return "", false
236 return "", false
239+func (p *OauthProxy) GetRedirect(req *http.Request) (string, error) {
240+ err := req.ParseForm()
246+ redirect := req.FormValue("rd")
252+ return redirect, err
239func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
255func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
240 // check if this is a redirect back at the end of oauth
256 // check if this is a redirect back at the end of oauth
241 remoteIP := req.Header.Get("X-Real-IP")
257 remoteIP := req.Header.Get("X-Real-IP")
@@ -246,13 +262,14 @@ func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
247 var ok bool
263 var ok bool
248 var user string
264 var user string
249− redirect := req.FormValue("rd")
255 if req.URL.Path == signInPath {
266 if req.URL.Path == signInPath {
267+ redirect, err := p.GetRedirect(req)
269+ p.ErrorPage(rw, 500, "Internal Error", err.Error())
256 user, ok = p.ManualSignIn(rw, req)
273 user, ok = p.ManualSignIn(rw, req)
258 p.SetCookie(rw, req, user)
275 p.SetCookie(rw, req, user)
@@ -263,8 +280,7 @@ func (p *OauthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
265 if req.URL.Path == oauthStartPath {
282 if req.URL.Path == oauthStartPath {
266− // get the ?rd= value
283+ redirect, err := p.GetRedirect(req)
267− err := req.ParseForm()
268 if err != nil {
284 if err != nil {
269 p.ErrorPage(rw, 500, "Internal Error", err.Error())
285 p.ErrorPage(rw, 500, "Internal Error", err.Error())