mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
A service needs values before it can serve: a signing key, a database URL, the client secret it mints with. The usual home for those is a Kubernetes Secret, which is a base64 field anyone holding get on the namespace reads, mounted into a filesystem where anything in the pod reads it again. An environment variable is inherited by every child process and printed by every crash dumper. secret.Boot reads them over the network at boot instead, into this process's memory, and authenticates with the identity the platform already vouches for: the ServiceAccount token projected into the pod. IAM exchanges that assertion for a bearer at its own token endpoint (RFC 7523 ยง2.1, grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer, served from IAM v1.34.99) and KMS answers GET /v1/kms/secrets/<path>/<key>?env=<env> under it. Nothing is issued to a service to let it do this, so there is no second credential to distribute or rotate. The contract is all-or-nothing. A missing key fails the whole Boot naming it, because a map one entry short is a service that starts, serves, and fails at the first request that needed the value. One mint per Boot and exactly one more on a 401 โ a second 401 is a refusal, and retrying it is how a boot loop becomes a mint flood against IAM. A key is a bare name, so it addresses a secret and never a place: without that check a `..` walks the KMS path up out of the caller's own subtree, which is what the test asserts by watching the address KMS is read at. The one fallback is a laptop: HANZO_DEV=1 with no token file reads each key from the environment under its own name and logs that it did. In production an absent token is an error. This module is the home for it, because every Hanzo Go service already depends on it. Co-authored-by: Hanzo Dev <[email protected]>