Raycynix.Extensions.Secrets 1.1.0

dotnet add package Raycynix.Extensions.Secrets --version 1.1.0
                    
NuGet\Install-Package Raycynix.Extensions.Secrets -Version 1.1.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="Raycynix.Extensions.Secrets" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Raycynix.Extensions.Secrets" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Raycynix.Extensions.Secrets" />
                    
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 Raycynix.Extensions.Secrets --version 1.1.0
                    
#r "nuget: Raycynix.Extensions.Secrets, 1.1.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 Raycynix.Extensions.Secrets@1.1.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=Raycynix.Extensions.Secrets&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Raycynix.Extensions.Secrets&version=1.1.0
                    
Install as a Cake Tool

Raycynix.Extensions.Secrets

Raycynix.Extensions.Secrets provides a unified secret-resolution layer for Raycynix applications.

It allows application code to ask for secrets through ISecretResolver while the actual values can come from the standard configuration pipeline or environment-specific fallback providers.

What it contains

  • AddRaycynixSecrets(...)
  • SecretOptions
  • ISecretProvider registrations
  • ISecretResolver
  • ISecretDiagnosticsResolver
  • GetRequiredSecretAsync(...)
  • ResolveWithSourceAsync(...)
  • ExplainSecretResolutionAsync(...)
  • configuration, environment, GitHub Actions, and TeamCity-style secret providers

What it does not contain

  • cloud-specific secret storage integrations
  • UI or interactive secret management
  • a custom secret file format

Why use it

IConfiguration is still the place where configuration is assembled, but Raycynix.Extensions.Secrets gives applications a separate API for secret access.

That separation is useful when you want to:

  • consume secrets through a dedicated abstraction instead of injecting raw IConfiguration
  • support multiple secret sources without changing application code
  • keep CI/CD-oriented environment variable resolution as a fallback when configuration does not contain a value

Usage

var builder = Host.CreateApplicationBuilder(args);

builder.Configuration.UseRaycynixConfigurationSources(options =>
{
    options.BaseFileName = "appsettings";
    options.EnvironmentName = builder.Environment.EnvironmentName;
    options.IncludeUserSecrets = builder.Environment.IsDevelopment();
});

builder.Services.AddRaycynixSecrets();

public sealed class GitHubTokenLoader(ISecretResolver secrets)
{
    public async Task<string?> LoadAsync(CancellationToken cancellationToken)
    {
        return await secrets.GetSecretAsync("GitHub:Token", cancellationToken);
    }
}

See the runnable example in examples/Raycynix.Extensions.Secrets.Example/Program.cs for a complete walkthrough of:

  • default provider precedence
  • custom provider precedence through SecretOptions
  • required-secret resolution
  • provider-aware resolution results
  • explain output that shows the evaluated provider chain

The package resolves secrets through a provider chain and returns the first available value.

By default, the provider chain checks sources in this order:

  1. IConfiguration
  2. exact environment variable key
  3. GitHub Actions-style normalized environment variable
  4. TeamCity-style normalized environment variable

This allows applications to keep using the standard configuration pipeline, including .NET User Secrets, while still consuming secrets through a dedicated ISecretResolver.

You can customize the provider order when the default precedence is not appropriate:

builder.Services.AddRaycynixSecrets(options =>
{
    options.ProviderOrder.Clear();
    options.ProviderOrder.Add(typeof(GitHubSecretProvider));
    options.ProviderOrder.Add(typeof(ConfigurationSecretProvider));
    options.ProviderOrder.Add(typeof(EnvironmentSecretProvider));
    options.ProviderOrder.Add(typeof(TeamCitySecretProvider));
});

Providers not listed in SecretOptions.ProviderOrder are still evaluated afterward in their registration order.

Examples:

  • ConnectionStrings:Main can be resolved from IConfiguration["ConnectionStrings:Main"]
  • or from the exact environment variable ConnectionStrings:Main
  • or from CONNECTIONSTRINGS_MAIN in GitHub Actions-style environments
  • or from env.ConnectionStrings.Main in TeamCity-style environments

You can also use the convenience APIs for required secrets and diagnostics:

var token = await secrets.GetRequiredSecretAsync("Api:Token", cancellationToken);

var resolved = await secrets.ResolveWithSourceAsync("ConnectionStrings:Main", cancellationToken);
Console.WriteLine(resolved.ProviderName);

var attempts = await secrets.ExplainSecretResolutionAsync("ConnectionStrings:Main", cancellationToken);
foreach (var attempt in attempts)
{
    Console.WriteLine($"{attempt.ProviderName}: {attempt.Succeeded}");
}

Typical output looks like this:

Default provider order
Configuration -> Environment -> GitHub -> TeamCity
GetSecretAsync: Server=config;Database=main;
ResolveWithSourceAsync.ProviderName: ConfigurationSecretProvider
GetRequiredSecretAsync(Api:Token): config-token
ExplainSecretResolutionAsync:
- ConfigurationSecretProvider: True

Custom provider order
GitHub -> Configuration -> Environment -> TeamCity
ResolveWithSourceAsync.Value: Server=github;Database=main;
ResolveWithSourceAsync.ProviderName: GitHubSecretProvider
ExplainSecretResolutionAsync:
- GitHubSecretProvider: True
Product 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. 
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.1.0 105 4/22/2026
1.0.1 94 4/20/2026
1.0.0 98 4/8/2026
0.1.2 100 4/8/2026

Added configuration-backed secret resolution, configurable provider ordering through SecretOptions, and provider-aware diagnostics APIs including required-secret resolution and explain output.