mirror of
https://github.com/coder/code-server.git
synced 2026-05-05 03:55:18 +02:00
fix: authentication check in path proxy (#5442)
`proxy` should `await` for result of `authenticated` call otherwise since otherwise it will always appear to be authenticated as the promise is truthy. Co-authored-by: Asher <ash@coder.com>
This commit is contained in:
committed by
GitHub
parent
c69f2c69f6
commit
2ec1e2de34
@@ -14,14 +14,14 @@ const getProxyTarget = (req: Request, passthroughPath?: boolean): string => {
|
||||
return `http://0.0.0.0:${req.params.port}/${req.params[0] || ""}${query ? `?${query}` : ""}`
|
||||
}
|
||||
|
||||
export function proxy(
|
||||
export async function proxy(
|
||||
req: Request,
|
||||
res: Response,
|
||||
opts?: {
|
||||
passthroughPath?: boolean
|
||||
},
|
||||
): void {
|
||||
if (!authenticated(req)) {
|
||||
): Promise<void> {
|
||||
if (!(await authenticated(req))) {
|
||||
// If visiting the root (/:port only) redirect to the login page.
|
||||
if (!req.params[0] || req.params[0] === "/") {
|
||||
const to = self(req)
|
||||
|
||||
Reference in New Issue
Block a user