- Shell 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| agents/proxy | ||
| assets/scripts | ||
| orders | ||
| tests | ||
| .gitignore | ||
| CHANGELOG.md | ||
| pack.toml | ||
| README.md | ||
gascity-openbao-pack
A Gas City pack that gives a city an OpenBao identity of its own. The agent proxy runs bao proxy for the city's token on a unix socket, and the order renew keeps the token alive. A client of the socket sends no token: the proxy forces the city's and caches what it reads.
The pack holds nothing about a particular server, token or socket. The city names all three.
Importing
-
Put the city's token in a file only the city's user can read.
-
Import the pack at the city level, and give the agent and the order their environment:
# pack.toml [imports.openbao] source = "https://sarak.sh/mikluko/gascity-openbao-pack.git" version = "^0.1" [[patches.agent]] name = "openbao.proxy" env = { BAO_ADDR = "https://bao.example.com", OPENBAO_TOKEN_FILE = "/home/city/.config/city/openbao-token", OPENBAO_SOCKET = "/home/city/.config/city/openbao.sock" }# city.toml [[orders.overrides]] name = "renew" env = { BAO_ADDR = "https://bao.example.com", OPENBAO_TOKEN_FILE = "/home/city/.config/city/openbao-token" }An exec order does not receive the agent's environment or
workspace.env, so the order gets its own. -
Read a secret through the socket to check it:
BAO_ADDR=unix:///home/city/.config/city/openbao.sock bao kv get -mount=kv some/path
A session provider that needs to be told the proxy has no terminal is told in the same patch; rexcity takes REXCITY_BOX = "process".
Reference
Agent proxy
An always-on named session of the city, one at a time, with no prompt. It starts assets/scripts/proxy.sh, which writes the configuration of bao proxy to .gc/runtime/packs/openbao/proxy.json and then becomes bao proxy.
| Variable | Meaning |
|---|---|
BAO_ADDR |
the OpenBao server |
OPENBAO_TOKEN_FILE |
the file that holds the token; read once, at start |
OPENBAO_SOCKET |
the unix socket to listen on, created with no access for group or others |
The script exits without starting the proxy when one of them is unset. A file left at OPENBAO_SOCKET is removed before the proxy starts. The proxy caches KV reads in memory and serves every request with the city's token, whatever token the client sends.
bao and jq must be on the supervisor's PATH.
Order renew
Renews the token in OPENBAO_TOKEN_FILE at BAO_ADDR every hour, with bao token renew. It talks to the server directly, so the token stays alive while the proxy is down. It needs BAO_ADDR and OPENBAO_TOKEN_FILE, given as under Importing.
Development
gc lint .
bash tests/proxy.sh
bash tests/renew.sh
The tests run the scripts against a stub bao, with nothing but bash and jq.
Releases
A pull request notes its change in a file of its own in .changelog/, a fragment, and never edits CHANGELOG.md. A fragment holds level-3 type headings and the notes under them, as they would read under [Unreleased]. test / changelog fails a pull request that adds none.
A release is a pull request that turns the fragments into a version section of CHANGELOG.md. Cut it on a branch from main with:
go run sarak.sh/mikluko/changelog/v2/cmd/changelog@latest release
When it merges, the release workflow tags the commit vX.Y.Z and creates the Forgejo release. An import follows the releases with version = "^0.N".