Archived
1
0

Proxy path fixes (#4548)

* Fix issue where HTTP error status codes are not read.

* Fix issues surrounding sessions when accessed from a proxy.

- Updated vscode args to match latest upstream.
- Fixed issues surrounding trailing slashes affecting base paths.
- Updated cookie names to better match upstream's usage, debuggability.

* Bump vendor.

* Update tests.

* Fix issue where tests lack cookie key.

Co-authored-by: Asher <ash@coder.com>
This commit is contained in:
Teffen
2021-12-01 19:21:52 -05:00
committed by GitHub
parent 6a2740f57e
commit 62b3a6fd9f
11 changed files with 39 additions and 27 deletions

View File

@ -1,17 +1,21 @@
import { Router } from "express"
import { CookieKeys } from "../../common/http"
import { getCookieDomain, redirect } from "../http"
import { Cookie } from "./login"
import { sanitizeString } from "../util"
export const router = Router()
router.get("/", async (req, res) => {
router.get<{}, undefined, undefined, { base?: string; to?: string }>("/", async (req, res) => {
const path = sanitizeString(req.query.base) || "/"
const to = sanitizeString(req.query.to) || "/"
// Must use the *identical* properties used to set the cookie.
res.clearCookie(Cookie.Key, {
res.clearCookie(CookieKeys.Session, {
domain: getCookieDomain(req.headers.host || "", req.args["proxy-domain"]),
path: req.query.base || "/",
path: decodeURIComponent(path),
sameSite: "lax",
})
const to = (typeof req.query.to === "string" && req.query.to) || "/"
return redirect(req, res, to, { to: undefined, base: undefined })
})