Skip to content

Commit 00838d0

Browse files
committed
Added the cookie-suffix flag and environment variable.
Fixes #7544 but is it the best way?
1 parent 472bf8a commit 00838d0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/common/http.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ export class HttpError extends Error {
2424
}
2525
}
2626

27-
export enum CookieKeys {
28-
Session = "code-server-session",
27+
export const CookieKeys = {
28+
Session: `code-server-session${process.env?.COOKIE_SUFFIX ? "-" + process.env?.COOKIE_SUFFIX : ""}`,
2929
}

src/node/cli.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface UserProvidedCodeArgs {
5353
"disable-getting-started-override"?: boolean
5454
"disable-proxy"?: boolean
5555
"session-socket"?: string
56+
"cookie-suffix"?: string
5657
"link-protection-trusted-domains"?: string[]
5758
// locale is used by both VS Code and code-server.
5859
locale?: string
@@ -172,6 +173,12 @@ export const options: Options<Required<UserProvidedArgs>> = {
172173
"session-socket": {
173174
type: "string",
174175
},
176+
"cookie-suffix": {
177+
type: "string",
178+
description:
179+
"Adds a suffix to the cookie. This can prevent a collision of cookies for subdomains, making them explixit. \n" +
180+
"Without this flag, no suffix is used. This can also be set with COOKIE_SUFFIX set to any string.",
181+
},
175182
"disable-file-downloads": {
176183
type: "boolean",
177184
description:
@@ -616,6 +623,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
616623
usingEnvPassword = false
617624
}
618625

626+
if (process.env.COOKIE_SUFFIX) {
627+
args["cookie-suffix"] = process.env.COOKIE_SUFFIX
628+
}
629+
619630
if (process.env.GITHUB_TOKEN) {
620631
args["github-auth"] = process.env.GITHUB_TOKEN
621632
}

0 commit comments

Comments
 (0)