Atulin.InfisicalConfig
1.0.0
dotnet add package Atulin.InfisicalConfig --version 1.0.0
NuGet\Install-Package Atulin.InfisicalConfig -Version 1.0.0
<PackageReference Include="Atulin.InfisicalConfig" Version="1.0.0" />
<PackageVersion Include="Atulin.InfisicalConfig" Version="1.0.0" />
<PackageReference Include="Atulin.InfisicalConfig" />
paket add Atulin.InfisicalConfig --version 1.0.0
#r "nuget: Atulin.InfisicalConfig, 1.0.0"
#:package Atulin.InfisicalConfig@1.0.0
#addin nuget:?package=Atulin.InfisicalConfig&version=1.0.0
#tool nuget:?package=Atulin.InfisicalConfig&version=1.0.0
Atulin.InfisicalConfig
A .NET configuration provider that fetches secrets from Infisical and injects them into
IConfiguration at startup. Supports retries, AOT compilation, and native integration with the .NET host builder.
Installation
dotnet add package Atulin.InfisicalConfig
Quick start
Call AddInfisicalAsync on your IHostApplicationBuilder before building the host:
var builder = WebApplication.CreateBuilder(args);
await builder.AddInfisicalAsync();
var app = builder.Build();
Secrets are available through the standard IConfiguration interface from that point on, including via IOptions<T> binding.
Configuration
Connection details are read from your existing configuration (e.g. appsettings.json, user secrets, or environment variables)
under the Infisical key by default:
{
"Infisical": {
"Url": "https://app.infisical.com",
"ProjectId": "your-project-id",
"MachineId": "your-machine-identity-client-id",
"ClientSecret": "your-machine-identity-client-secret",
"Env": "prod",
"SecretPath": "/",
"Prefix": "",
"ExpandSecretReferences": true,
"IncludeImports": true
}
}
| Field | Required | Default | Description |
|---|---|---|---|
Url |
✓ | — | Base URL of your Infisical instance |
ProjectId |
✓ | — | Infisical project ID |
MachineId |
✓ | — | Machine identity client ID |
ClientSecret |
✓ | — | Machine identity client secret |
Env |
dev |
Infisical environment slug | |
SecretPath |
/ |
Path within the environment to fetch secrets from | |
Prefix |
(none) | Prepended to every secret key (see Key mapping) | |
ExpandSecretReferences |
true |
Resolve secret references on the Infisical side | |
IncludeImports |
true |
Include imported secrets |
Tip: In production, supply
MachineIdandClientSecretvia environment variables rather thanappsettings.jsonto avoid committing credentials.
Binder options
Pass a delegate to AddInfisicalAsync to adjust retry and transport behaviour:
await builder.AddInfisicalAsync(cfg =>
{
cfg.MaxRetries = 3;
cfg.Prefix = "Infisical";
cfg.OnRetry = (attempt, max, delay, ex) =>
logger.LogWarning(ex, "Infisical unreachable ({Attempt}/{Max}), retrying in {Delay}s",
attempt, max, delay.TotalSeconds);
});
| Property | Default | Description |
|---|---|---|
MaxRetries |
5 |
Number of attempts before throwing. Uses exponential backoff starting at 2 s |
Prefix |
"Infisical" |
Configuration section key to read connection options from |
OnRetry |
null |
Callback invoked after each failed attempt (see below) |
HttpMessageHandlerFactory |
null |
Factory for a custom HttpMessageHandler, e.g. for SSL or proxy configuration |
Retry callback
OnRetry receives the attempt number, the configured maximum, the upcoming delay, and the exception:
cfg.OnRetry = (attempt, max, delay, ex) =>
Console.Error.WriteLine($"[Infisical] Attempt {attempt}/{max} failed, retrying in {delay.TotalSeconds}s: {ex.Message}");
If OnRetry is null, transient failures are silently retried. Exhausting all attempts, or encountering a non-network error, throws immediately.
Custom HTTP handler
Use HttpMessageHandlerFactory to customise transport-level behaviour such as SSL certificates or proxies.
The library takes ownership of each returned handler.
// Trust a self-signed certificate on a private Infisical instance
cfg.HttpMessageHandlerFactory = () => new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (_, cert, _, _) =>
cert?.Thumbprint == "YOUR_CERT_THUMBPRINT";
};
Key mapping
Infisical secret keys are mapped to IConfiguration keys with two transformations applied:
- Double underscores (
__) are replaced with:to represent configuration hierarchy, matching the standard .NET convention for environment variables. - If
Prefixis set in the Infisical options, it is prepended to every key.
Given Prefix = "MyApp", a secret named Database__ConnectionString becomes MyApp:Database:ConnectionString in IConfiguration, bindable as:
builder.Services.Configure<DatabaseOptions>(
builder.Configuration.GetSection("MyApp:Database"));
AOT compatibility
The library is fully AOT and trim compatible. Add the following to your project to take advantage of the configuration binding source generator:
<PropertyGroup>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
</PropertyGroup>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 104 | 6/2/2026 |