From 8535fa18366452ce5a9df99a7aaf4a7a055e90a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Sun, 7 Nov 2021 15:16:56 +0000 Subject: [PATCH 1/4] rename `connectionToken` to `connection-token` --- resources/server/bin-dev/code-web.js | 2 +- src/vs/server/remoteExtensionHostAgentServer.ts | 6 +++--- src/vs/server/serverEnvironmentService.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/server/bin-dev/code-web.js b/resources/server/bin-dev/code-web.js index d5276fb41d0..0fdb7c76d2c 100644 --- a/resources/server/bin-dev/code-web.js +++ b/resources/server/bin-dev/code-web.js @@ -61,7 +61,7 @@ if (ENABLE_SYNC) { } // Connection Token -serverArgs.push('--connectionToken', '00000'); +serverArgs.push('--connection-token', '00000'); // Server should really only listen from localhost serverArgs.push('--host', '127.0.0.1'); diff --git a/src/vs/server/remoteExtensionHostAgentServer.ts b/src/vs/server/remoteExtensionHostAgentServer.ts index d755bca9589..89cc2b57878 100644 --- a/src/vs/server/remoteExtensionHostAgentServer.ts +++ b/src/vs/server/remoteExtensionHostAgentServer.ts @@ -914,8 +914,8 @@ export class RemoteExtensionHostAgentServer extends Disposable { function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string; connectionTokenIsMandatory: boolean; } { if (args['connection-secret']) { - if (args['connectionToken']) { - console.warn(`Please do not use the argument connectionToken at the same time as connection-secret.`); + if (args['connection-token']) { + console.warn(`Please do not use the argument connection-token at the same time as connection-secret.`); process.exit(1); } let rawConnectionToken = fs.readFileSync(args['connection-secret']).toString(); @@ -926,7 +926,7 @@ function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string } return { connectionToken: rawConnectionToken, connectionTokenIsMandatory: true }; } else { - return { connectionToken: args['connectionToken'] || generateUuid(), connectionTokenIsMandatory: false }; + return { connectionToken: args['connection-token'] || generateUuid(), connectionTokenIsMandatory: false }; } } diff --git a/src/vs/server/serverEnvironmentService.ts b/src/vs/server/serverEnvironmentService.ts index 2e8a3ef9394..3715cfb25c1 100644 --- a/src/vs/server/serverEnvironmentService.ts +++ b/src/vs/server/serverEnvironmentService.ts @@ -11,7 +11,7 @@ import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/envi export const serverOptions: OptionDescriptions = { 'port': { type: 'string' }, - 'connectionToken': { type: 'string' }, + 'connection-token': { type: 'string' }, 'connection-secret': { type: 'string', description: nls.localize('connection-secret', "Path to file that contains the connection token. This will require that all incoming connections know the secret.") }, 'host': { type: 'string' }, 'socket-path': { type: 'string' }, @@ -58,7 +58,7 @@ export const serverOptions: OptionDescriptions = { export interface ServerParsedArgs { port?: string; - connectionToken?: string; + 'connection-token'?: string; /** * A path to a filename which will be read on startup. * Consider placing this file in a folder readable only by the same user (a `chmod 0700` directory). From 9d4a8af6372219b7ee178efd20f0beac77ffaa9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Tue, 9 Nov 2021 15:57:05 +0000 Subject: [PATCH 2/4] Deprecate `connection-token` --- src/vs/server/remoteExtensionHostAgentServer.ts | 6 +++++- src/vs/server/serverEnvironmentService.ts | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vs/server/remoteExtensionHostAgentServer.ts b/src/vs/server/remoteExtensionHostAgentServer.ts index 89cc2b57878..4d2d3b53692 100644 --- a/src/vs/server/remoteExtensionHostAgentServer.ts +++ b/src/vs/server/remoteExtensionHostAgentServer.ts @@ -913,6 +913,10 @@ export class RemoteExtensionHostAgentServer extends Disposable { } function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string; connectionTokenIsMandatory: boolean; } { + if (args['connectionToken']) { + console.warn(`The argument connectionToken is deprecated, please use connection-token instead`); + } + if (args['connection-secret']) { if (args['connection-token']) { console.warn(`Please do not use the argument connection-token at the same time as connection-secret.`); @@ -926,7 +930,7 @@ function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string } return { connectionToken: rawConnectionToken, connectionTokenIsMandatory: true }; } else { - return { connectionToken: args['connection-token'] || generateUuid(), connectionTokenIsMandatory: false }; + return { connectionToken: args['connection-token'] || args['connectionToken'] || generateUuid(), connectionTokenIsMandatory: false }; } } diff --git a/src/vs/server/serverEnvironmentService.ts b/src/vs/server/serverEnvironmentService.ts index 3715cfb25c1..d9e927c04ee 100644 --- a/src/vs/server/serverEnvironmentService.ts +++ b/src/vs/server/serverEnvironmentService.ts @@ -59,6 +59,10 @@ export const serverOptions: OptionDescriptions = { export interface ServerParsedArgs { port?: string; 'connection-token'?: string; + /** + * @deprecated use `connection-token` instead + */ + connectionToken?: string; /** * A path to a filename which will be read on startup. * Consider placing this file in a folder readable only by the same user (a `chmod 0700` directory). From 90ae587a5586fc6c933b58c166683d77937082a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Mon, 15 Nov 2021 16:49:26 +0000 Subject: [PATCH 3/4] Fix indentation --- src/vs/server/serverEnvironmentService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/server/serverEnvironmentService.ts b/src/vs/server/serverEnvironmentService.ts index e82cb341d82..c3992fba47f 100644 --- a/src/vs/server/serverEnvironmentService.ts +++ b/src/vs/server/serverEnvironmentService.ts @@ -12,7 +12,7 @@ import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/envi export const serverOptions: OptionDescriptions = { 'port': { type: 'string' }, 'pick-port': { type: 'string' }, - 'connection-token': { type: 'string' }, + 'connection-token': { type: 'string' }, 'connection-secret': { type: 'string', description: nls.localize('connection-secret', "Path to file that contains the connection token. This will require that all incoming connections know the secret.") }, 'host': { type: 'string' }, 'socket-path': { type: 'string' }, @@ -64,7 +64,7 @@ export interface ServerParsedArgs { * @deprecated use `connection-token` instead */ connectionToken?: string; - 'pick-port'?: string; + 'pick-port'?: string; /** * A path to a filename which will be read on startup. * Consider placing this file in a folder readable only by the same user (a `chmod 0700` directory). From 27a61bd9852cb8b808af99f0acedd3b5d3b9afd5 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Sat, 20 Nov 2021 13:04:52 +0100 Subject: [PATCH 4/4] Small tweaks --- src/vs/server/remoteExtensionHostAgentServer.ts | 4 ++-- src/vs/server/serverEnvironmentService.ts | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/vs/server/remoteExtensionHostAgentServer.ts b/src/vs/server/remoteExtensionHostAgentServer.ts index b41ccdeb138..60f925fe191 100644 --- a/src/vs/server/remoteExtensionHostAgentServer.ts +++ b/src/vs/server/remoteExtensionHostAgentServer.ts @@ -914,12 +914,12 @@ export class RemoteExtensionHostAgentServer extends Disposable { function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string; connectionTokenIsMandatory: boolean; } { if (args['connectionToken']) { - console.warn(`The argument connectionToken is deprecated, please use connection-token instead`); + console.warn(`The argument '--connectionToken' is deprecated, please use '--connection-token' instead`); } if (args['connection-secret']) { if (args['connection-token']) { - console.warn(`Please do not use the argument connection-token at the same time as connection-secret.`); + console.warn(`Please do not use the argument '--connection-token' at the same time as '--connection-secret'.`); process.exit(1); } let rawConnectionToken = fs.readFileSync(args['connection-secret']).toString(); diff --git a/src/vs/server/serverEnvironmentService.ts b/src/vs/server/serverEnvironmentService.ts index c3992fba47f..a014d82f701 100644 --- a/src/vs/server/serverEnvironmentService.ts +++ b/src/vs/server/serverEnvironmentService.ts @@ -12,7 +12,8 @@ import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/envi export const serverOptions: OptionDescriptions = { 'port': { type: 'string' }, 'pick-port': { type: 'string' }, - 'connection-token': { type: 'string' }, + 'connectionToken': { type: 'string' }, // deprecated in favor of `--connection-token` + 'connection-token': { type: 'string', description: nls.localize('connection-token', "A secret that must be included by the web client with all requests.") }, 'connection-secret': { type: 'string', description: nls.localize('connection-secret', "Path to file that contains the connection token. This will require that all incoming connections know the secret.") }, 'host': { type: 'string' }, 'socket-path': { type: 'string' }, @@ -59,12 +60,22 @@ export const serverOptions: OptionDescriptions = { export interface ServerParsedArgs { port?: string; - 'connection-token'?: string; + 'pick-port'?: string; /** * @deprecated use `connection-token` instead */ connectionToken?: string; - 'pick-port'?: string; + /** + * A secret token that must be provided by the web client with all requests. + * Use only `[0-9A-Za-z\-]`. + * + * By default, a UUID will be generated every time the server starts up. + * + * If the server is running on a multi-user system, then consider + * using `--connection-secret` which has the advantage that the token cannot + * be seen by other users using `ps` or similar commands. + */ + 'connection-token'?: string; /** * A path to a filename which will be read on startup. * Consider placing this file in a folder readable only by the same user (a `chmod 0700` directory).