You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(ocm-cli): add file and keychain credential backends with auth commands (#327)
* feat(ocm-cli): add file and keychain credential backends with auth commands
* feat(ocm-cli): refactor credentials into async TokenStore architecture
Replace the credential-backend module with a TokenStore interface and
file/keychain implementations behind an internal facade. Convert token
get/set/delete to async, add env-token precedence warnings on login and
logout, and surface store availability in status. Add token-store tests
and helpers; remove the old credential modules and tests. Bump to 0.2.6.
* fix(ocm-cli): keep tokens out of security argv and stop masking config read errors
Route every macOS Keychain call through `security -i`, sending the quoted
command on stdin so the token is never visible in process arguments. Reject
arguments containing line breaks, which would otherwise inject additional
security commands.
Let unexpected state file read failures propagate so a broken config dir is
reported instead of being reduced to "no manager configured", and stop
consuming the install notice when reading it fails unexpectedly.
---------
Co-authored-by: CS <chris@chriswritescode.dev>
The token is stored in the macOS Keychain under the manager URL. The manager URL is persisted to `~/.config/opencode-manager/state.json`.
79
+
The token is stored in a platform-specific token store: the macOS Keychain (service `opencode-manager`, account = manager URL) on macOS, or `~/.config/opencode-manager/credentials.json` at mode `0600` on Linux. On Linux the token is plaintext JSON protected only by file permissions. Run `ocm status` to see the active store. The manager URL itself is persisted to `~/.config/opencode-manager/state.json`.
80
+
81
+
Windows is not supported: the CLI falls back to the same file store, but the `0600` mode is not enforced there and hidden token entry requires `bash`.
80
82
81
83
Generate or rotate your internal token from **Settings → Manager Token** in the Manager web UI (Settings cog in the sidebar, then **Manager Token**).
82
84
@@ -88,7 +90,7 @@ Generate or rotate your internal token from **Settings → Manager Token** in th
88
90
ocm Attach to the Manager repo matching $PWD's git origin,
89
91
or fall back to the last selected repo
90
92
ocm login <url> [token] Save manager URL + token (token via stdin if omitted)
91
-
ocm logout Forget saved token (Keychain) and state
93
+
ocm logout Forget saved token and state
92
94
ocm status Show current manager URL, repo, and whether token is set
93
95
ocm list List ready repos from the manager
94
96
ocm use <repoId|name> Attach to a specific repo and remember it as last
@@ -141,14 +143,15 @@ When the TUI plugin entry is installed, `/ocm-move` is available in local OpenCo
141
143
142
144
## 4. Environment variables
143
145
144
-
Both can be used in place of `ocm login`:
146
+
The CLI's environment and token inputs:
145
147
146
148
| Variable | Description |
147
149
|---|---|
148
150
|`OPENCODE_MANAGER_URL`| Manager base URL (e.g., `https://manager.example.com`). Not currently consumed by the CLI — use `ocm login`. |
149
151
|`OCM_REMOTE_MANAGER_URL`| Internal child-process context set by `ocm attach`; controls the remote TUI indicator. Not a login setting. |
150
152
|`OCM_REMOTE_REPO_NAME`| Internal child-process context set by `ocm attach`; labels the remote TUI indicator. Not a login setting. |
151
-
| Keychain entry under `https://manager.example.com`| Token used for Bearer auth on Manager API calls and Basic auth on the OpenCode proxy. |
153
+
|`OCM_TOKEN`| Read-only override for the stored token; takes priority over the platform token store. `ocm login` never writes it, and `ocm logout` cannot remove it. Because the manager URL still comes from `state.json`, CI must run `ocm login` first, so this override does not yet avoid writing a token to disk. |
154
+
| Token store entry under `<manager url>`| Token used for Bearer auth on Manager API calls and Basic auth on the OpenCode proxy. macOS Keychain (service `opencode-manager`) or `~/.config/opencode-manager/credentials.json` (mode `0600`) on Linux. |
| Linux |`~/.config/opencode-manager/credentials.json`, mode `0600`|
31
+
32
+
On Linux the token is stored as plaintext JSON protected only by file
33
+
permissions. CLI state is stored at `~/.config/opencode-manager/state.json`.
34
+
Windows is unsupported: the same file store is used, but the `0600` mode is not
35
+
enforced there.
36
+
37
+
`OCM_TOKEN` overrides the token store for reads; `ocm login` always writes to
38
+
the platform store and `ocm logout` cannot remove the override. Run `ocm status`
39
+
to see the active store.
40
+
41
+
If `[token]` is omitted, `ocm login` reads it from hidden TTY input (requires
42
+
`bash`) or stdin.
29
43
30
44
## Commands
31
45
@@ -92,7 +106,9 @@ global installs); the plugin surface is TUI-only.
92
106
93
107
## Requirements
94
108
109
+
- macOS or Linux (Windows is unsupported)
95
110
-`opencode` available on `PATH`
96
111
-`git` and `tar` (with gzip support, i.e. the `-z` flag) available on `PATH`
97
-
- macOS `security` CLI for Keychain-backed token storage
112
+
-`bash`, used for hidden token entry and interactive confirmations
113
+
- macOS only: `/usr/bin/security`, used for Keychain-backed token storage (Linux uses a mode-`0600` file under the user config dir `~/.config/opencode-manager`)
0 commit comments