Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions components/osapi-lab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<id>`. 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
Expand Down
2 changes: 1 addition & 1 deletion components/osapi/agent-skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -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://<vault>/<key>`. `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`
Expand Down
19 changes: 11 additions & 8 deletions components/osapi/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: .../<nil>`, 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: .../<nil>`, 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.
Expand Down
2 changes: 1 addition & 1 deletion components/osapi/secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).

Expand Down
28 changes: 20 additions & 8 deletions components/osapi/vaults.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down Expand Up @@ -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
Expand All @@ -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
```

Expand Down
Loading