Fly.ioExplainer
Operationalizing Macaroons
Summary
Operationalizing Macaroons at Fly.io requires treating them as online-stateful bearer tokens whose nonces must be checked against database state, while keeping root secrets away from the primary API cluster. The team built tkdb, a roughly 5,000-line Go service backed by encrypted SQLite managed with LiteFS and Litestream, deployed on isolated hardware across the US, Europe, and Australia. Its HTTP/Noise interface supports verification and restricted signing, while FlyCast routing, retries, and client-side caching reduce the impact of unreliable global connectivity; verification caching exceeds 98%. Revocation uses blacklist state, and third-party caveats let services such as flyd obtain narrowly scoped secret-reading authority through tkdb rather than holding broad credentials. OpenTelemetry, standard metrics, and a retained OpenSearch audit trail provide visibility, while the post concludes that Macaroons’ internal infrastructure benefits outweigh limited user adoption.
Context
Macaroon verification is online-stateful because each token’s nonce must be looked up in a database. Fly.io wanted to keep that state and the root secrets used to protect it out of the primary API cluster because API instability could affect deployed applications, and because secure design favors isolating sensitive secrets from complicated code. Global connectivity problems also make transoceanic verification links undesirable.
Approach / What changed
Fly.io created tkdb, a deliberately simple Go service managing encrypted SQLite with LiteFS and Litestream on isolated hardware in the US, Europe, and Australia. It exposes verification and signing APIs over HTTP/Noise, uses FlyCast routing and retry behavior, and relies on client-side verification caching. Revocation is stored in database state, while third-party caveats and narrowly distributed signing credentials minimize service privileges. OpenTelemetry, Prometheus metrics, and a permanently retained OpenSearch audit trail support operations and investigation.
Takeaways
tkdb is approximately 5,000 lines of Go and uses encrypted SQLite managed by LiteFS and Litestream; the database is only a couple dozen megabytes after several years of Macaroon use.
Macaroon verification caching exceeds 98% because a verified token contains enough information to verify more-specific descendants produced through the chaining HMAC construction.
flyd receives a secret-reading Macaroon with a third-party caveat, requiring tkdb to verify organization permissions instead of granting every worker broad access to user secrets.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.