Commit 514f021
committed
fix(cli): persist login token durably on detached/headless boxes
`instant login` from a detached/headless context (e.g. `nohup instant
login &` on an agent box) printed "✓ Logged in" while persisting NOTHING
the next `instant whoami` could read — so the very next command said
"Not logged in". This undercuts the "frictionless for agents" promise.
Root cause: cliconfig.Save() trusted secretstore.Set()'s nil return as
proof of durable persistence. On a detached box the keychain backend's
Available() probe is a false positive (a probing Get returning ErrNotFound
reads as "available, just empty"), and the subsequent Set returns nil even
though the write lands in an ephemeral/locked session keyring the NEXT
process can't read.
Fix: new persistSecret() in cliconfig does write-then-readback validation.
If Set returns success but the immediate Get either errors or returns a
mismatched value, persistSecret falls through to the 0600 file fallback
so the token lands in ~/.instant-config. If both keychain and file fail,
runLogin returns an error with the raw token + an `export INSTANT_TOKEN=…`
escape hatch — no more false-success banner on a totally-failed persist.1 parent 6c6a5df commit 514f021
2 files changed
Lines changed: 62 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
156 | 163 | | |
157 | 164 | | |
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
161 | 168 | | |
162 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
99 | 139 | | |
100 | 140 | | |
101 | 141 | | |
| |||
177 | 217 | | |
178 | 218 | | |
179 | 219 | | |
180 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
181 | 225 | | |
182 | 226 | | |
183 | 227 | | |
184 | | - | |
| 228 | + | |
185 | 229 | | |
186 | 230 | | |
187 | | - | |
| 231 | + | |
| 232 | + | |
188 | 233 | | |
189 | 234 | | |
190 | 235 | | |
| |||
0 commit comments