Repository navigation
Commit 9f01e1e
authored
Add 1Password brokered credential vault commands (#271)
Depends on kernel/kernel#4256; built against kernel-go-sdk v0.114.0,
which includes that API.
## Summary
- `vaults` and `vaults credentials` help give agents a decision order
before any credential is created:
1. Reuse an existing credential found with `items list <vault> -o json`.
2. Otherwise ask the user where the login lives and wait for the answer.
The options are Kernel-hosted collection or 1Password brokered approval.
The 1Password option only works for the user's own non-shared vault;
shared-vault items and passkeys are not supported.
3. If 1Password is unavailable, can't be connected, or is declined,
offer Kernel-hosted collection instead of switching silently.
The help also says never to ask for passwords, OAuth codes, tokens, or
keys in the terminal or chat, and that a submitted form is not proof of
sign-in.
- `vaults credentials connect <vault> <account-key> --provider
1password` creates or reuses a `credential_account` item with the
Kernel-managed OAuth client and shows the 1Password authorization URL.
Running it again on a failed or declined link starts a new
authorization. If the item advertises `1pw_recover`, invoke that first,
then connect again.
- `vaults credentials create` sends `provider`. A spec without one
defaults to `kernel`: the generated SDK requires the field, and the API
still accepts an omitted provider as legacy Kernel input.
- A `1password` spec takes `account` (a `credential_account` key in the
same vault) and v2 `requests` with 1-5 login entries.
- It can instead take stored-token fields: `access_token` +
`integration_key`. Supply either `account` or both secrets, never both.
The CLI rejects invalid combinations before any API call.
- `vaults items invoke` supports `1pw_create_access_request`,
`1pw_access_request_status`, `1pw_fill` (with optional `entry_id` to
pick one of several approved entries on the same origin),
`1pw_update_access_token`, and `1pw_recover`, each only when the item
advertises it.
- Parameters are strict: unknown or duplicate keys are rejected, and the
CLI adds `type` itself.
- `1pw_update_access_token` takes only `access_token`, and accepts it
only through `--spec-file`/stdin; `--params` is rejected so the token
never appears in command-line arguments.
- There is no reset or reconcile operation. After an uncertain outcome,
the help and errors say to stop and tell the user, not retry or delete
and recreate the item. Only after a confirmed `failed` status, and with
the user's agreement, may the agent recreate the credential for one new
request.
- Error guidance for 1Password operations:
- 400/403/404: rejected.
- 409: not currently available; do not reset.
- 503, or 500 `provider_unavailable` on connect: 1Password is
unavailable here; offer Kernel-hosted collection.
- Any other 5xx or a transport failure: outcome unknown; stop.
- Response bodies are never echoed.
- Output stays display-safe:
- It shows `account`; `access_token` and `integration_key` are never
shown, and stored-token credentials display as "stored token
(developer-supplied)".
- Text output lists request entry IDs for choosing `entry_id`.
- `items list` gains a Site column: the description for Kernel
credentials, the requested websites for 1Password credentials.
- The native
`onepassword://grant-brokered-access?access_request_reference=…` link is
shown only on a `1password_access_approval` action with exactly that
shape.
## Not included
- The CLI still sends only the Kernel-managed OAuth client for
credential accounts; there is no 1Password vault-provider-config
command.
- `credentials update` covers Kernel-hosted credentials only.
## SDK
`go.mod` requires `github.com/kernel/kernel-go-sdk v0.114.0` (commit
`b307cc10fdfab032069c951663312e04d0203b5b`); the temporary
private-preview `replace` is gone. Its `vaultitem.go` is identical to
the #4256 preview this PR was developed against.
## Validation
- `go vet ./...` and `go test ./...` against v0.114.0: all pass.
- `cmd/vaults_onepassword_test.go` covers:
- exact request bodies for connect, account-backed and stored-token
create, and each operation, including `entry_id` and token update
- validation with no API call on invalid input: account/secret
exclusivity, 1-5 entries, `--params` rejected for token updates, and
extra keys on token updates
- operation and connect error guidance, including the not-advertised
hint
- fill outcomes and exit codes
- redaction of secrets, response bodies, and forged approval links
- the `items list` Site column
- the help decision guidance
- Not run: `golangci-lint`, and any call against a live API.
---------
Co-authored-by: rgarcia <72655+rgarcia@users.noreply.github.com>1 parent 643c26b commit 9f01e1e
12 files changed
Lines changed: 1034 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
141 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
142 | 151 | | |
143 | 152 | | |
144 | 153 | | |
145 | 154 | | |
146 | | - | |
| 155 | + | |
147 | 156 | | |
148 | 157 | | |
149 | 158 | | |
150 | 159 | | |
151 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
152 | 176 | | |
153 | 177 | | |
154 | 178 | | |
| |||
212 | 236 | | |
213 | 237 | | |
214 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
215 | 242 | | |
216 | 243 | | |
217 | | - | |
218 | | - | |
| 244 | + | |
| 245 | + | |
219 | 246 | | |
220 | 247 | | |
221 | 248 | | |
| |||
240 | 267 | | |
241 | 268 | | |
242 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
243 | 273 | | |
244 | 274 | | |
245 | 275 | | |
246 | 276 | | |
247 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
248 | 281 | | |
249 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
250 | 286 | | |
251 | 287 | | |
252 | 288 | | |
| |||
259 | 295 | | |
260 | 296 | | |
261 | 297 | | |
262 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
263 | 302 | | |
264 | 303 | | |
265 | 304 | | |
266 | 305 | | |
267 | | - | |
| 306 | + | |
268 | 307 | | |
269 | 308 | | |
270 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
| |||
122 | 128 | | |
123 | 129 | | |
124 | 130 | | |
125 | | - | |
| 131 | + | |
126 | 132 | | |
127 | 133 | | |
128 | 134 | | |
| |||
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
188 | | - | |
189 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
190 | 216 | | |
191 | 217 | | |
192 | 218 | | |
193 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
194 | 224 | | |
195 | 225 | | |
196 | 226 | | |
197 | 227 | | |
198 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
199 | 232 | | |
200 | | - | |
201 | | - | |
| 233 | + | |
| 234 | + | |
202 | 235 | | |
203 | 236 | | |
204 | 237 | | |
| |||
212 | 245 | | |
213 | 246 | | |
214 | 247 | | |
215 | | - | |
216 | | - | |
| 248 | + | |
| 249 | + | |
217 | 250 | | |
218 | 251 | | |
219 | 252 | | |
| |||
0 commit comments