We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9045919 commit bbf2e24Copy full SHA for bbf2e24
src/node/cli.ts
@@ -84,6 +84,7 @@ export interface UserProvidedArgs extends UserProvidedCodeArgs {
84
"trusted-origins"?: string[]
85
version?: boolean
86
"proxy-domain"?: string[]
87
+ "skip-auth-preflight"?: boolean
88
"reuse-window"?: boolean
89
"new-window"?: boolean
90
"ignore-last-opened"?: boolean
@@ -252,6 +253,10 @@ export const options: Options<Required<UserProvidedArgs>> = {
252
253
description: "GitHub authentication token (can only be passed in via $GITHUB_TOKEN or the config file).",
254
},
255
"proxy-domain": { type: "string[]", description: "Domain used for proxying ports." },
256
+ "skip-auth-preflight": {
257
+ type: "boolean",
258
+ description: "Allows preflight requests through proxy without authentication.",
259
+ },
260
"ignore-last-opened": {
261
type: "boolean",
262
short: "e",
src/node/main.ts
@@ -163,6 +163,9 @@ export const runCodeServer = async (
163
logger.info(` - ${plural(args["proxy-domain"].length, "Proxying the following domain")}:`)
164
args["proxy-domain"].forEach((domain) => logger.info(` - ${domain}`))
165
}
166
+ if (args["skip-auth-preflight"]) {
167
+ logger.info(" - Skipping authentication for preflight requests")
168
+ }
169
if (process.env.VSCODE_PROXY_URI) {
170
logger.info(`Using proxy URI in PORTS tab: ${process.env.VSCODE_PROXY_URI}`)
171
src/node/routes/domainProxy.ts
@@ -61,6 +61,11 @@ router.all(/.*/, async (req, res, next) => {
61
62
ensureProxyEnabled(req)
63
64
+ if (req.method === "OPTIONS" && req.args["skip-auth-preflight"]) {
65
+ // Allow preflight requests with `skip-auth-preflight` flag
66
+ return next()
67
68
+
69
// Must be authenticated to use the proxy.
70
const isAuthenticated = await authenticated(req)
71
if (!isAuthenticated) {
src/node/routes/pathProxy.ts
@@ -26,7 +26,9 @@ export async function proxy(
26
): Promise<void> {
27
28
29
- if (!(await authenticated(req))) {
30
31
+ } else if (!(await authenticated(req))) {
32
// If visiting the root (/:port only) redirect to the login page.
33
if (!req.params.path || req.params.path === "/") {
34
const to = self(req)
test/unit/node/cli.test.ts
@@ -108,6 +108,8 @@ describe("parser", () => {
108
109
["--abs-proxy-base-path", "/codeserver/app1"],
110
111
+ "--skip-auth-preflight",
112
113
["--session-socket", "/tmp/override-code-server-ipc-socket"],
114
115
["--host", "0.0.0.0"],
@@ -146,6 +148,7 @@ describe("parser", () => {
146
148
"bind-addr": "192.169.0.1:8080",
147
149
"session-socket": "/tmp/override-code-server-ipc-socket",
150
"abs-proxy-base-path": "/codeserver/app1",
151
+ "skip-auth-preflight": true,
152
})
153
154
test/unit/node/proxy.test.ts
@@ -268,6 +268,21 @@ describe("proxy", () => {
268
const text = await resp.text()
269
expect(text).toBe("app being served behind a prefixed path")
270
271
272
+ it("should not allow OPTIONS without authentication by default", async () => {
273
+ process.env.PASSWORD = "test"
274
+ codeServer = await integration.setup(["--auth=password"])
275
+ const resp = await codeServer.fetch(proxyPath, { method: "OPTIONS" })
276
+ expect(resp.status).toBe(401)
277
+ })
278
279
+ it("should allow OPTIONS with `skip-auth-preflight` flag", async () => {
280
281
+ codeServer = await integration.setup(["--auth=password", "--skip-auth-preflight"])
282
+ e.post("/wsup", (req, res) => {})
283
284
+ expect(resp.status).toBe(200)
285
286
287
288
// NOTE@jsjoeio
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments