diff --git a/pkg/api/user_token.go b/pkg/api/user_token.go index 12894a1a103..b8aaac1b26b 100644 --- a/pkg/api/user_token.go +++ b/pkg/api/user_token.go @@ -88,11 +88,11 @@ func (hs *HTTPServer) RotateUserAuthTokenRedirect(c *contextmodel.ReqContext) re return response.Redirect(hs.GetRedirectURL(c)) } - redirectTo := c.Query("redirectTo") + redirectTo := hs.Cfg.AppSubURL + c.Query("redirectTo") if err := hs.ValidateRedirectTo(redirectTo); err != nil { return response.Redirect(hs.Cfg.AppSubURL + "/") } - return response.Redirect(hs.Cfg.AppSubURL + redirectTo) + return response.Redirect(redirectTo) } // swagger:route POST /user/auth-tokens/rotate diff --git a/pkg/services/authn/authn.go b/pkg/services/authn/authn.go index 94a78bf4da3..204fb0c2410 100644 --- a/pkg/services/authn/authn.go +++ b/pkg/services/authn/authn.go @@ -281,7 +281,7 @@ func handleLogin(r *http.Request, w http.ResponseWriter, cfg *setting.Cfg, ident scopedRedirectToCookie, err := r.Cookie(redirectToCookieName) if err == nil { redirectTo, _ := url.QueryUnescape(scopedRedirectToCookie.Value) - if redirectTo != "" && validator(redirectTo) == nil { + if redirectTo != "" && validator(cfg.AppSubURL+redirectTo) == nil { redirectURL = cfg.AppSubURL + redirectTo } cookies.DeleteCookie(w, redirectToCookieName, cookieOptions(cfg))