From 7765ab3756d8d04fdc0eb028a9887eb2b6da8d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D7=A0=CF=85=CE=B1=CE=B7=20=D7=A0=CF=85=CE=B1=CE=B7=D1=95?= =?UTF-8?q?=CF=83=CE=B7?= Date: Fri, 27 Nov 2026 16:50:02 -0800 Subject: [PATCH] docs(osapi): add secret create secret create makes a key, with the name in the body. An update of a key or a file that is not there is 404. Location takes several fields. Co-Authored-By: Claude Opus 5.5 --- components/osapi-lab/README.md | 23 ++++++++++++----------- components/osapi/agent-skills.md | 2 +- components/osapi/endpoints.md | 19 +++++++++++-------- components/osapi/secrets.md | 2 +- components/osapi/vaults.md | 28 ++++++++++++++++++++-------- 5 files changed, 45 insertions(+), 29 deletions(-) diff --git a/components/osapi-lab/README.md b/components/osapi-lab/README.md index 500dbe8..297ba39 100644 --- a/components/osapi-lab/README.md +++ b/components/osapi-lab/README.md @@ -473,17 +473,18 @@ token with the `kid` of `lab`. The controller keeps the signing keys in its vault, as an operator does, and `hub.yaml` refers to them as `secret://default/jwt-signing-key-`. The controller resolves the references at its start. The controller role writes each -key with `osapi client secret update`, from standard input, when the vault does -not hold it. A record in the JetStream store, `jetstream/signing-keys.in-vault`, -says that the vault holds them. The record is in the store because the vault is, -and it counts only while the store's data, `jetstream/jetstream/`, is there. -Thus the first run after a teardown, or after the store or only its data is -removed, finds no record that counts. It starts the controller with the keys -themselves, writes them, and then starts it again on the references -(osapi-io/osapi-lab#54, #96). Both starts of the controller name the same list -of files that it reads, so the next run does not start it again. A NATS password -and the key of a vault cannot be a reference, because osapi needs them before it -reads a vault. +key with `osapi client secret create`, from standard input, when the vault does +not hold it, and with `osapi client secret update` when the vault holds a +different value. A record in the JetStream store, +`jetstream/signing-keys.in-vault`, says that the vault holds them. The record is +in the store because the vault is, and it counts only while the store's data, +`jetstream/jetstream/`, is there. Thus the first run after a teardown, or after +the store or only its data is removed, finds no record that counts. It starts +the controller with the keys themselves, writes them, and then starts it again +on the references (osapi-io/osapi-lab#54, #96). Both starts of the controller +name the same list of files that it reads, so the next run does not start it +again. A NATS password and the key of a vault cannot be a reference, because +osapi needs them before it reads a vault. `cli.yaml` on your machine holds the keys themselves. Thus `osapi controller token generate` on your machine signs a token that the diff --git a/components/osapi/agent-skills.md b/components/osapi/agent-skills.md index 9c18731..240afed 100644 --- a/components/osapi/agent-skills.md +++ b/components/osapi/agent-skills.md @@ -190,7 +190,7 @@ only for the part that it uses. 4. Check the `status` of each host in a result. A command against many hosts succeeds when some of them fail, and `skipped` is neither. 5. Give a secret as a reference. Put the value in a vault with - `osapi client secret update --value -`, from standard input, then give + `osapi client secret create --value -`, from standard input, then give `secret:///`. `osapi client secret list` gives the keys. A value in a flag, a plan or a file stays in the shell history or on the disk. Each secret field marks its two forms in `method get` diff --git a/components/osapi/endpoints.md b/components/osapi/endpoints.md index adc2ed7..3f91b19 100644 --- a/components/osapi/endpoints.md +++ b/components/osapi/endpoints.md @@ -15,10 +15,10 @@ The issue is osapi#744. ## Why -The controller has 45 operations, in ten groups. Before osapi#744, a person +The controller has 46 operations, in ten groups. Before osapi#744, a person wrote each one four times: the spec, the handler, the service of the SDK and the CLI command. Each one comes from a definition now: admission (6), agent (8), -audit (3), catalog (1), file (6), health (3), job (5), pki (6), secret (6) and +audit (3), catalog (1), file (6), health (3), job (5), pki (6), secret (7) and telemetry (1). `osapi dsl endpoint list` gives the groups and their methods. A new operation of the controller had no generator. Behaviors cover the work on @@ -55,11 +55,11 @@ The definitions must express each row before the first group moves. | agent | facts, list, get, drain, undrain | a fixed sub-path beside the key (`/agent/facts`), so the order of the routes is important; a key in the path (`{hostname}`); actions on the key (`/agent/{hostname}/drain`) | | audit | list, get, export | pagination (`limit`, `offset`) and a total; an export of each entry | | catalog | get | one document, not a list; an enum of the spec from a registry (`Permission`, `OperationID`); the permission `catalog:read`, which each built-in role has | -| file | list, stale, get, upload, update, delete | a multipart upload; 201 with `Location`; 200 for a file that exists; 409; 503 when no Object Store is set | +| file | list, stale, get, upload, update, delete | a multipart upload; 201 with `Location`; 200 for a file that exists; 409; 404 for an update of a file that is not there; 503 when no Object Store is set | | health | liveness, ready, status | no auth for liveness and ready, which probes call; 503; the permission `health:read` | | job | list, get, delete, retry | a filter (`status`); 204 with no body; a JSON body; 201 | | pki | cert list, cert get, tls list, tls get, key get, key rotate, nats get, nats rotate | a filter of the host and of the component; the TLS section of a component, which joins the crypto of its registration with its certificates from `cert list`, read one time for each request | -| secret | vaults, list, get, update, delete | a key of two fields in the path, `.Key("vault", "key")`; a command under a word that is not in the path, `.CommandSub("vault")`; a `secret.Value` in the body, which is never in a log or a span | +| secret | vaults, list, get, create, update, delete | a key of two fields in the path, `.Key("vault", "key")`; a command under a word that is not in the path, `.CommandSub("vault")`; a `secret.Value` in the body, which is never in a log or a span | | telemetry | get | a permission with a different name (`trace:read`); 503 when the backend is not set | The 94 operations under `/api/node/{hostname}` are host work. They become @@ -143,11 +143,14 @@ var Group = endpoint.Register(endpoint.Define( skill tells when to use it. - **`Location` and `Example[T]`** name a field by its json name. - `endpoint validate` checks the names, under the rule `field`: the field that + `endpoint validate` checks the names, under the rule `field`: each field that `Location` names is a json field of the output, and the field that - `Example[T]` names is a json field of `T`. Before the rule, a misspelled name - gave the header `Location: .../`, or dropped the example from the spec, - with no error. + `Example[T]` names is a json field of `T`. `Location` takes one field or more. + The header is the path of the group, then the value of each field, joined by + `/` and escaped, such as `/api/secret/default/registry-token` for + `.Location("vault", "key")`. Before the rule, a misspelled name gave the + header `Location: .../`, or dropped the example from the spec, with no + error. - **An example** names the flags of the method's command. Under the rule `example`, `endpoint validate` refuses a flag that the command does not have. diff --git a/components/osapi/secrets.md b/components/osapi/secrets.md index 86ab313..f3c2ed1 100644 --- a/components/osapi/secrets.md +++ b/components/osapi/secrets.md @@ -208,7 +208,7 @@ Built in osapi-io/osapi#1248. A coding agent learns about a secret from the same generated parts as a person. `method get` and the docs page of a method mark each secret field and its two forms. `osapi client secret list` gives the names to reference. Rule 5 of the skill in the binary tells it to put a value in with -`osapi client secret update` from standard input, then use its reference +`osapi client secret create` from standard input, then use its reference ([Agent skills](agent-skills.md#what-the-skill-tells-an-agent)). The Plans page of the UI has a picker of the references ([The UI](ui.md#plans)). diff --git a/components/osapi/vaults.md b/components/osapi/vaults.md index a8dccd8..cf5de70 100644 --- a/components/osapi/vaults.md +++ b/components/osapi/vaults.md @@ -290,6 +290,7 @@ commands and their pages. | GET | `/api/secret` | `secret:read` | `osapi client secret vault list` | | GET | `/api/secret/{vault}` | `secret:read` | `osapi client secret list` | | GET | `/api/secret/{vault}/{key}` | `secret:read` | `osapi client secret get` | +| POST | `/api/secret/{vault}` | `secret:write` | `osapi client secret create` | | PUT | `/api/secret/{vault}/{key}` | `secret:write` | `osapi client secret update` | | DELETE | `/api/secret/{vault}/{key}` | `secret:write` | `osapi client secret delete` | | GET | `/api/secret/{vault}/{key}/value` | `secret:reveal` | `osapi client secret reveal` | @@ -320,14 +321,24 @@ answer. - `vault list` gives each vault of `controller.secrets.vaults`, with its type, its targets, and `answers`: true when the vault gave a list of its keys. -- `update` writes the value as the next version of the key, or as version 1 of a - new key, and answers 200 with the metadata. The body is `{"value": "..."}`, a - `secret.Value` of at most 64 KiB. The route puts the subject of the token in - the context with `vault.WithActor`, so `by` is who wrote it. A reference as - the value resolves first, as in each route +- `create` writes the value as version 1 of a new key, and answers 201 with the + metadata and a `Location` header, `/api/secret/{vault}/{key}`. The body is + `{"key": "...", "value": "..."}`, with the name in the body, as each create + has it. A key that exists is 409, whatever its value, and `update` changes it. + `create` checks only that the key is in the list of the vault. It never reads + the value of the key. + +- `update` writes the value as the next version of a key that exists, and + answers 200 with the metadata. A key that is not there is 404: `create` makes + it. The body is `{"value": "..."}`. Each value is a `secret.Value` of at most + 64 KiB. Each write puts the subject of the token in the context with + `vault.WithActor`, so `by` is who wrote it. A reference as the value resolves + first, as in each route ([How a route resolves a reference](#how-a-route-resolves-a-reference)). Thus - `update` with `secret://default/other` copies the value of that key, and needs - `secret:use`. + `create` or `update` with `secret://default/other` copies the value of that + key, and needs `secret:use`. `create` lists the keys first, then writes. The + vault has no write that only creates, so two creates of one new key at the + same time can both write. - A vault that the config does not name is 404, and so is a key that is not in its vault. A vault name and a key are letters, digits, `-` and `_`, the rule @@ -338,7 +349,8 @@ The CLI reads the value from standard input with `--value -`. It refuses a literal value in a flag, because the shell history keeps it: ```bash -osapi client secret update --vault default --key registry-token --value - < token.txt +osapi client secret create --vault default --key registry-token --value - < token.txt +osapi client secret update --vault default --key registry-token --value - < new-token.txt osapi client secret list --vault default ```