.NET
Updated
krypticdev plugs into the standard configuration system: one call on your builder
and every secret is available through IConfiguration, options binding, and DI. Outside
development it is a no-op, and it never throws.
Install
dotnet add package krypticdev
Use
using KrypticDev;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddKryptic(); // that's the entire integration
// Secrets are ordinary configuration now:
var connectionString = builder.Configuration["DATABASE_URL"];
AddKryptic() also sets the values as environment variables so libraries that read
Environment.GetEnvironmentVariable directly see them too.
Behavior
- No-op when
ASPNETCORE_ENVIRONMENT/DOTNET_ENVIRONMENTis notDevelopment, or whenKRYPTIC_DISABLED=true. - Finds
kryptic.jsonby walking up from the working directory. - Existing environment variables and earlier configuration sources are never overwritten.
- macOS/Linux via unix socket, Windows via named pipe (
NamedPipeClientStream).
Options
builder.Configuration.AddKryptic(options =>
{
options.Environment = "staging"; // default: kryptic.json defaultEnvironment
options.ProjectId = "proj_x"; // default: kryptic.json projectId
options.SocketTimeoutMs = 2000;
options.FallbackSilently = true; // suppress the missing-daemon warning
});
Environment variables override everything: KRYPTIC_PROJECT_ID, KRYPTIC_ENV,
KRYPTIC_SOCKET_PATH, KRYPTIC_TIMEOUT_MS, KRYPTIC_DISABLED, KRYPTIC_SILENT.