Repository navigation
Support --remote-token-file for direct desktop remote connections - #349361
francoisnt wants to merge 21 commits into
Conversation
…n-file # Conflicts: # src/vs/platform/windows/electron-main/windowsStateHandler.ts
Add an integration regression test verifying that ordinary remote reconnections retain the initial resolved connection token as a session snapshot when the underlying connection-token file changes on disk. This confirms maintainer-approved snapshot semantics and ensures that mutations or replacements to the token file during an active session are not adopted during ordinary network reconnection loops. References microsoft#344076
…ect-snapshot test: preserve resolved connection token during ordinary reconnection
…feature/remote-token-file
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
🟡 Changes recommended
Reconnection rereads the token file instead of retaining the session’s original token, so replacing or deleting the file can change credentials or block reconnection.
1 open issue
What changed in this PR
Adds desktop --remote-token-file support for direct --remote host:port connections, allowing external launchers to authenticate without a resolver extension.
Changes:
- Adds CLI validation and window-scoped credential access through the native host service.
- Reuses the server token format while preserving remote-host confirmation and adding reload, restart, and restore handling.
- Adds documentation and tests for validation, credential isolation, authority resolution, and lifecycle behavior.
| File | Description |
|---|---|
src/vs/workbench/test/electron-browser/workbenchTestServices.ts |
Adds the native token-service test stub. |
src/vs/workbench/services/extensions/test/common/directRemoteAuthority.test.ts |
Tests token lookup, confirmation, and failures. |
src/vs/workbench/services/extensions/electron-browser/nativeExtensionService.ts |
Integrates authenticated direct resolution. |
src/vs/workbench/services/extensions/common/directRemoteAuthority.ts |
Resolves direct connections after host confirmation. |
src/vs/server/test/node/serverConnectionToken.test.ts |
Tests desktop/server token compatibility. |
src/vs/server/node/serverConnectionToken.ts |
Uses shared token validation and parsing. |
src/vs/platform/windows/test/electron-main/windowsStateHandler.test.ts |
Tests persistence of the authentication requirement. |
src/vs/platform/windows/electron-main/windowsStateHandler.ts |
Stores and retrieves the non-secret restore marker. |
src/vs/platform/windows/electron-main/windowsMainService.ts |
Manages credential bindings across window operations. |
src/vs/platform/windows/electron-main/windows.ts |
Extends window-service and launch contracts. |
src/vs/platform/window/common/window.ts |
Adds the authentication requirement to window configuration. |
src/vs/platform/remote/test/node/remoteConnectionToken.test.ts |
Tests token files, isolation, recovery, and reconnect behavior. |
src/vs/platform/remote/test/node/fixtures/remoteConnectionTokenProcess.ts |
Exercises token handling in a child process. |
src/vs/platform/remote/test/common/connectionToken.test.ts |
Tests shared token-format rules. |
src/vs/platform/remote/README.md |
Documents usage, security, lifecycle, and validation. |
src/vs/platform/remote/node/remoteConnectionToken.ts |
Implements token-file validation and window-scoped bindings. |
src/vs/platform/remote/common/connectionToken.ts |
Defines shared token validation and parsing. |
src/vs/platform/native/electron-main/nativeHostMainService.ts |
Delegates window-specific token requests. |
src/vs/platform/native/common/native.ts |
Adds the native token lookup contract. |
src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts |
Sanitizes token-bearing relaunch arguments. |
src/vs/platform/launch/electron-main/launchMainService.ts |
Routes token-bearing launches through window loading. |
src/vs/platform/environment/test/node/argv.test.ts |
Tests relaunch argument sanitization. |
src/vs/platform/environment/node/argvHelper.ts |
Validates arguments and strips transient relaunch options. |
src/vs/platform/environment/node/argv.ts |
Registers the CLI option and help text. |
src/vs/platform/environment/common/argv.ts |
Adds the parsed argument type. |
src/vs/code/node/cli.ts |
Validates token files before desktop launch. |
src/vs/code/electron-main/main.ts |
Reports token-related startup failures. |
Review effort: Balanced
|
Hi Connor Peet (@connor4312) , thanks for clarifying the token snapshot behavior in #344076. This PR implements it for direct desktop connections. The reconnect regression test verifies that changing the token file during a session leaves ordinary reconnects using the original token. When you have a chance, could you take a look and let me know whether this is the direction you’d want? |
|
Hi Alexandru Dima (@alexdima), would you be the right person to review this change to direct remote connections? The PR implements the session snapshot behavior discussed with Connor Peet (@connor4312) in #344076, and I've resolved the conflicts with upstream. In the meantime, would it be possible to approve the CI workflows so I can address any build or test failures ahead of the review? Thanks! |
|
While waiting for upstream CI approval, I ran independent validation on my fork against the current PR revision (79b8ed1). Client compilation, TypeScript type checking, and all targeted Node.js and Electron tests passed, including the reconnection regression test. |

Summary
Fixes #344076.
Add
--remote-token-fileto the desktop CLI so external launchers can authenticate direct--remote host:portconnections. For example, a launcher can start a token-protected VS Code Server in a container, forward its port over SSH, and open the remote project without a resolver extension.The option accepts an absolute local file path and uses the existing server token-file format and authentication handshake. Missing, unreadable, or invalid files fail the connection. Existing remote-host confirmation still applies.
Credential lifetime
Testing
Automated coverage includes token-file parsing and validation, window credential isolation, restart arguments, window state, and direct authority resolution. The reconnect regression test replaces the file after initial resolution, clears and re-resolves the authority, and verifies that the reconnect loop still receives the original token. Thanks to Putluru Sandeep (@sunny-kavixo) for contributing the original regression test.
How to verify the desktop flow
--connection-token-file. With the desktop app already running, use the command above with a local file containing the same token. The remote folder should open and authenticate.