Skip to content

Commit 05d0b29

Browse files
committed
Revert "feat: store session tokens in the OS keyring (#808)"
This reverts commit 80f0c0a.
1 parent 5fc228c commit 05d0b29

23 files changed

+155
-1275
lines changed

esbuild.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const buildOptions = {
3232
// undefined when bundled to CJS, causing runtime errors.
3333
openpgp: "./node_modules/openpgp/dist/node/openpgp.min.cjs",
3434
},
35-
external: ["vscode", "@napi-rs/keyring"],
35+
external: ["vscode"],
3636
sourcemap: production ? "external" : true,
3737
minify: production,
3838
plugins: watch ? [logRebuildPlugin] : [],

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export default defineConfig(
154154

155155
// Build config - ESM with Node globals
156156
{
157-
files: ["esbuild.mjs", "scripts/*.mjs"],
157+
files: ["esbuild.mjs"],
158158
languageOptions: {
159159
globals: {
160160
...globals.node,

package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"test:integration": "tsc -p test --outDir out --noCheck && node esbuild.mjs && vscode-test",
3333
"test:webview": "vitest --project webview",
3434
"typecheck": "concurrently -g \"tsc --noEmit\" \"tsc --noEmit -p test\"",
35-
"vscode:prepublish": "pnpm build:production && node scripts/vendor-keyring.mjs",
35+
"vscode:prepublish": "pnpm build:production",
3636
"watch": "concurrently -n extension,webviews \"pnpm watch:extension\" \"pnpm watch:webviews\"",
3737
"watch:extension": "node esbuild.mjs --watch",
3838
"watch:webviews": "pnpm -r --filter \"./packages/*\" --parallel dev"
@@ -156,11 +156,6 @@
156156
"type": "string"
157157
}
158158
},
159-
"coder.useKeyring": {
160-
"markdownDescription": "Store session tokens in the OS keyring (macOS Keychain, Windows Credential Manager) instead of plaintext files. Requires CLI >= 2.29.0. Has no effect on Linux.",
161-
"type": "boolean",
162-
"default": true
163-
},
164159
"coder.httpClientLogLevel": {
165160
"markdownDescription": "Controls the verbosity of HTTP client logging. This affects what details are logged for each HTTP request and response.",
166161
"type": "string",
@@ -468,7 +463,6 @@
468463
"word-wrap": "1.2.5"
469464
},
470465
"dependencies": {
471-
"@napi-rs/keyring": "^1.2.0",
472466
"@peculiar/x509": "^1.14.3",
473467
"@repo/shared": "workspace:*",
474468
"axios": "1.13.6",

pnpm-lock.yaml

Lines changed: 0 additions & 135 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,3 @@ onlyBuiltDependencies:
2727
- keytar
2828
- unrs-resolver
2929
- utf-8-validate
30-
31-
# Install @napi-rs/keyring native binaries for macOS and Windows so they're
32-
# available when building the universal VSIX (even on Linux CI).
33-
# Only macOS and Windows use the keyring; Linux falls back to file storage.
34-
supportedArchitectures:
35-
os:
36-
- current
37-
- darwin
38-
- win32
39-
cpu:
40-
- current
41-
- x64
42-
- arm64

scripts/vendor-keyring.mjs

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/api/workspace.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { spawn } from "node:child_process";
88
import * as vscode from "vscode";
99

10-
import { type CliAuth, getGlobalFlags } from "../cliConfig";
10+
import { getGlobalFlags } from "../cliConfig";
1111
import { type FeatureSet } from "../featureSet";
1212
import { escapeCommandArg } from "../util";
1313
import { type UnidirectionalStream } from "../websocket/eventStreamConnection";
@@ -50,7 +50,7 @@ export class LazyStream<T> {
5050
*/
5151
export async function startWorkspaceIfStoppedOrFailed(
5252
restClient: Api,
53-
auth: CliAuth,
53+
globalConfigDir: string,
5454
binPath: string,
5555
workspace: Workspace,
5656
writeEmitter: vscode.EventEmitter<string>,
@@ -65,7 +65,7 @@ export async function startWorkspaceIfStoppedOrFailed(
6565

6666
return new Promise((resolve, reject) => {
6767
const startArgs = [
68-
...getGlobalFlags(vscode.workspace.getConfiguration(), auth),
68+
...getGlobalFlags(vscode.workspace.getConfiguration(), globalConfigDir),
6969
"start",
7070
"--yes",
7171
createWorkspaceIdentifier(workspace),

src/cliConfig.ts

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1+
import { type WorkspaceConfiguration } from "vscode";
2+
13
import { getHeaderArgs } from "./headers";
2-
import { isKeyringSupported } from "./keyringStore";
34
import { escapeCommandArg } from "./util";
45

5-
import type { WorkspaceConfiguration } from "vscode";
6-
7-
import type { FeatureSet } from "./featureSet";
8-
9-
export type CliAuth =
10-
| { mode: "global-config"; configDir: string }
11-
| { mode: "url"; url: string };
12-
136
/**
147
* Returns the raw global flags from user configuration.
158
*/
@@ -21,61 +14,21 @@ export function getGlobalFlagsRaw(
2114

2215
/**
2316
* Returns global configuration flags for Coder CLI commands.
24-
* Includes either `--global-config` or `--url` depending on the auth mode.
17+
* Always includes the `--global-config` argument with the specified config directory.
2518
*/
2619
export function getGlobalFlags(
2720
configs: Pick<WorkspaceConfiguration, "get">,
28-
auth: CliAuth,
21+
configDir: string,
2922
): string[] {
30-
const authFlags =
31-
auth.mode === "url"
32-
? ["--url", escapeCommandArg(auth.url)]
33-
: ["--global-config", escapeCommandArg(auth.configDir)];
34-
3523
// Last takes precedence/overrides previous ones
3624
return [
3725
...getGlobalFlagsRaw(configs),
38-
...authFlags,
26+
"--global-config",
27+
escapeCommandArg(configDir),
3928
...getHeaderArgs(configs),
4029
];
4130
}
4231

43-
/**
44-
* Returns true when the user has keyring enabled and the platform supports it.
45-
*/
46-
export function isKeyringEnabled(
47-
configs: Pick<WorkspaceConfiguration, "get">,
48-
): boolean {
49-
return isKeyringSupported() && configs.get<boolean>("coder.useKeyring", true);
50-
}
51-
52-
/**
53-
* Single source of truth: should the extension use the OS keyring for this session?
54-
* Requires CLI >= 2.29.0, macOS or Windows, and the coder.useKeyring setting enabled.
55-
*/
56-
export function shouldUseKeyring(
57-
configs: Pick<WorkspaceConfiguration, "get">,
58-
featureSet: FeatureSet,
59-
): boolean {
60-
return isKeyringEnabled(configs) && featureSet.keyringAuth;
61-
}
62-
63-
/**
64-
* Resolves how the CLI should authenticate: via the keyring (`--url`) or via
65-
* the global config directory (`--global-config`).
66-
*/
67-
export function resolveCliAuth(
68-
configs: Pick<WorkspaceConfiguration, "get">,
69-
featureSet: FeatureSet,
70-
deploymentUrl: string,
71-
configDir: string,
72-
): CliAuth {
73-
if (shouldUseKeyring(configs, featureSet)) {
74-
return { mode: "url", url: deploymentUrl };
75-
}
76-
return { mode: "global-config", configDir };
77-
}
78-
7932
/**
8033
* Returns SSH flags for the `coder ssh` command from user configuration.
8134
*/

0 commit comments

Comments
 (0)