RatelKey.Burrow.Sdk
1.1.1
See the version list below for details.
dotnet add package RatelKey.Burrow.Sdk --version 1.1.1
NuGet\Install-Package RatelKey.Burrow.Sdk -Version 1.1.1
<PackageReference Include="RatelKey.Burrow.Sdk" Version="1.1.1" />
<PackageVersion Include="RatelKey.Burrow.Sdk" Version="1.1.1" />
<PackageReference Include="RatelKey.Burrow.Sdk" />
paket add RatelKey.Burrow.Sdk --version 1.1.1
#r "nuget: RatelKey.Burrow.Sdk, 1.1.1"
#:package RatelKey.Burrow.Sdk@1.1.1
#addin nuget:?package=RatelKey.Burrow.Sdk&version=1.1.1
#tool nuget:?package=RatelKey.Burrow.Sdk&version=1.1.1
Burrow SDK for .NET
Read secrets from a self-hosted RatelKey Burrow with a machine identity.
- Single and structured secrets, and individual fields of a structured secret.
- The machine's own access map (
ListProjectsAsync,ListSecretsAsync). - Certificate pinning, or standard CA trust (
TlsMode). - Live secrets that follow every change on the Burrow (
LiveAsync,LiveEnvironmentAsync). - An OIDC token instead of a key (
Burrow.Oidc). - Verifying the Burrow's signed webhooks (
BurrowWebhooks.Verify).
Requirements
- .NET 8+.
- One dependency:
BouncyCastle.Cryptography, for Ed25519.
Install
dotnet add package RatelKey.Burrow.Sdk
Bootstrap a machine
From the Burrow dashboard, Machines → Add machine, and run the install it gives you on the target host.
The identity lands at ~/.burrow/burrows/<slug>/identity.json.
Quick start
using RatelKey.Burrow;
// The single machine identity on this host (under ~/.burrow, or $BURROW_HOME).
using var burrow = Burrow.Open();
// A single-value secret:
var apiKey = (await burrow.GetSecretAsync("payments/prod/API_KEY")).Value;
// A structured secret, one read, projected locally with no re-fetch:
var db = await burrow.GetSecretAsync("payments/prod/DATABASE");
var all = db.ToDictionary(); // every field, name to value
var host = db.GetField("host"); // one field
var fields = db.GetFields("username", "password"); // in the order given
// What this machine can read:
foreach (var p in await burrow.ListProjectsAsync())
Console.WriteLine($"{p.Project}: {string.Join(", ", p.Categories)}");
Point it at a specific identity by selector or path:
Burrow.Open("burrow-a1b2c3d4e5f60718"); // slug / name / machine id / URL
Burrow.Open("/home/you/.burrow/burrows/burrow-a1b2c3d4e5f60718"); // path (a burrow dir or identity.json)
Without ~/.burrow
For an app that manages its own key material:
using var burrow = Burrow.Connect(
burrowUrl: "https://burrow.internal:12010",
machineId: "...",
privateKeyPem: Environment.GetEnvironmentVariable("BURROW_MACHINE_KEY")!); // PKCS#8 PEM
Live secrets
A live handle holds a secret's current value and follows every change on the Burrow as it happens.
var db = await burrow.LiveAsync("payments/prod/DATABASE");
db.GetField("password"); // always the current value
db.Changed += (_, change) => pool.Reconnect(change.Next);
burrow.LiveEnvironmentAsync("payments/prod") does the same for a whole environment: env.Get("API_KEY"), and
Changed lists what changed, was added or was removed.
- The call completes after the first read. A missing secret or grant is refused there.
- All live handles on a client share one connection. It reconnects on its own and re-reads anything that changed while it was down.
StatusisLive,Reconnecting,Revoked(access was taken away) orRemoved(deleted on the Burrow). The last two are final, and the handle keeps its last value.- Handlers run on the SDK's background threads. One that throws is reported on
Error. CloseAsync()or disposing the client closes every handle.- Needs a Burrow with live updates; an older one is refused at
LiveAsync.
In-memory identity
Enroll with a machine token's code from the Burrow's Machine tokens page. The key stays in memory and nothing is written to disk. The code carries the Burrow's address and certificate trust.
await using var burrow = Burrow.Enroll(Environment.GetEnvironmentVariable("BURROW_ENROLL_CODE")!);
var db = await burrow.GetSecretAsync("payments/prod/DATABASE");
- The machine enrolls on the first read and renews itself with the same code before it expires.
Burrow.Open()enrolls fromBURROW_ENROLL_CODEwhen the host has no identity under~/.burrow.CloseAsync()or disposing the client ends the machine at once, so it shows as expired on the Burrow.- Only a machine token's code works here. A one-time invitation is refused.
OIDC
using var burrow = Burrow.Oidc(
burrowUrl: "https://burrow.example.com",
fingerprint: Environment.GetEnvironmentVariable("BURROW_FINGERPRINT")); // omit for a publicly-trusted certificate
var apiKey = (await burrow.GetSecretAsync("payments/prod/API_KEY")).Value;
audience defaults to burrowUrl. GitHub Actions requires permissions: id-token: write. GitLab CI/CD (gitlab.com) requires the job to declare its token as RATEL_ID_TOKEN:
id_tokens:
RATEL_ID_TOKEN:
aud: https://burrow.example.com
Bitbucket Pipelines requires the step to list the Burrow as an OIDC audience:
- step:
oidc:
audiences:
- https://burrow.example.com
Certificate trust
using var burrow = Burrow.Open(tls: TlsMode.SystemTrust);
Without an explicit tls, the SDK uses the trust chosen when the machine was added: encrypted by default (works everywhere), or verified against the Burrow's own key or a CA if that was selected.
TlsMode.Pinned: trust-on-first-use, stored at~/.burrow/burrows/<slug>/known_cert.TlsMode.PinnedTo("aa:bb:..."): a fixed fingerprint (from the Burrow's network settings).TlsMode.SystemTrust: CA and hostname verification, for a Burrow on a custom domain or Let's Encrypt.TlsMode.Insecure: no verification; accepts any certificate. Opt-in only, for a network you already trust. Shortcut:Burrow.Open().InsecureTls().
Webhooks
Verify a delivery from a Burrow's Signed webhook. Needs only the webhook's signing secret, not a machine identity.
app.MapPost("/hooks/burrow", async (HttpRequest request) =>
{
using var body = new MemoryStream();
await request.Body.CopyToAsync(body);
var e = BurrowWebhooks.Verify(body.ToArray(), request.Headers[BurrowWebhooks.SignatureHeader],
Environment.GetEnvironmentVariable("BURROW_WEBHOOK_SECRET")!);
Console.WriteLine($"{e.Event} {e.Data.Summary}");
return Results.NoContent();
});
Pass the raw body, before JSON parsing. A retry of the same event carries the same e.Id, so keep the ids you've handled to ignore repeats.
Errors
Every failure is a BurrowException: BurrowAuthException (401), BurrowForbiddenException (403, no grant),
BurrowNotFoundException (404), BurrowServerException (5xx), BurrowCertificateException (pin mismatch),
BurrowTransportException (unreachable or unparsable), BurrowIdentityException (no, ambiguous or invalid
identity), plus two projection errors on the result: SecretShapeException (e.g. Value on a structured
secret) and FieldNotFoundException. The message carries the Burrow's own reason. BurrowWebhooks.Verify
throws BurrowWebhookException for a missing or wrong signature.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- BouncyCastle.Cryptography (>= 2.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.