GCScript.Configuration.Infisical 1.0.0

dotnet add package GCScript.Configuration.Infisical --version 1.0.0
                    
NuGet\Install-Package GCScript.Configuration.Infisical -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GCScript.Configuration.Infisical" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GCScript.Configuration.Infisical" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="GCScript.Configuration.Infisical" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GCScript.Configuration.Infisical --version 1.0.0
                    
#r "nuget: GCScript.Configuration.Infisical, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GCScript.Configuration.Infisical@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GCScript.Configuration.Infisical&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=GCScript.Configuration.Infisical&version=1.0.0
                    
Install as a Cake Tool

GCScript.Configuration.Infisical

Loads secrets from Infisical into Microsoft.Extensions.Configuration, on top of the official Infisical.Sdk. Secrets are read once, when the configuration is built, and are never exported to the process environment.

Install

dotnet add package GCScript.Configuration.Infisical

Usage

HostApplicationBuilder builder = Host.CreateApplicationBuilder();
builder.Configuration.AddInfisical();

builder.Services.AddOptions<AcmeApiOptions>()
	.Bind(builder.Configuration)
	.ValidateDataAnnotations()
	.ValidateOnStart();
// appsettings.json — not secrets
{
  "Infisical": {
    "SiteUrl": "https://infisical.example.com",
    "ProjectId": "00000000-0000-0000-0000-000000000000",
    "Environment": "prod"
  }
}

The credentials of a machine identity (Universal Auth) come from Infisical's standard environment variables, shared with the CLI and the official SDKs:

[Environment]::SetEnvironmentVariable('INFISICAL_UNIVERSAL_AUTH_CLIENT_ID', '<client id>', 'User')
[Environment]::SetEnvironmentVariable('INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET', '<client secret>', 'User')

Secrets land at the configuration root with their Infisical name. Map them onto options classes with [ConfigurationKeyName]:

public sealed class AcmeApiOptions {
	[Required, Url, ConfigurationKeyName("ACME_API_URL")] public string BaseUrl { get; init; } = "";
	[Required, ConfigurationKeyName("ACME_API_TOKEN")] public string Token { get; init; } = "";
}

Multiple projects

Call AddInfisical once per project, each with its own section. Settings in Infisical apply to every project and the named section overrides them:

builder.Configuration
	.AddInfisical("Infisical:Shared")
	.AddInfisical("Infisical:App");
{
  "Infisical": {
    "SiteUrl": "https://infisical.example.com",
    "Shared": { "ProjectId": "11111111-1111-1111-1111-111111111111" },
    "App": { "ProjectId": "22222222-2222-2222-2222-222222222222" }
  }
}

When two projects define the same key, the one added last wins. The machine identity needs access to every project it reads.

Settings

Setting Default Source
SiteUrl https://app.infisical.com Infisical:SiteUrl
ProjectId Infisical:ProjectId
Environment prod Infisical:Environment
SecretPath / Infisical:SecretPath
Recursive true Infisical:Recursive
ClientId INFISICAL_UNIVERSAL_AUTH_CLIENT_ID
ClientSecret INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET
Timeout 00:00:30 Infisical:Timeout

Anything can be set in code instead, with or without appsettings.json:

builder.Configuration.AddInfisical(o => {
	o.SiteUrl = "https://infisical.example.com";
	o.ProjectId = "00000000-0000-0000-0000-000000000000";
	o.Environment = "dev";
});

With Recursive, secret keys must be unique across folders (e.g. ACME_API_TOKEN, not API_TOKEN).

Errors

Incomplete settings, rejected credentials and unreachable servers all throw InfisicalConfigurationException while the configuration is built. The message names what failed and never includes secret values: if the underlying SDK error echoes the Client ID or Client Secret, they are masked as *** and the original exception is not attached, so ToString() and loggers cannot leak them either.

License

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 43 9/17/2026