Alvecta.Foundation.Infrastructure.Secrets 7.1.76

There is a newer version of this package available.
See the version list below for details.
dotnet add package Alvecta.Foundation.Infrastructure.Secrets --version 7.1.76
                    
NuGet\Install-Package Alvecta.Foundation.Infrastructure.Secrets -Version 7.1.76
                    
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="Alvecta.Foundation.Infrastructure.Secrets" Version="7.1.76" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Alvecta.Foundation.Infrastructure.Secrets" Version="7.1.76" />
                    
Directory.Packages.props
<PackageReference Include="Alvecta.Foundation.Infrastructure.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 Alvecta.Foundation.Infrastructure.Secrets --version 7.1.76
                    
#r "nuget: Alvecta.Foundation.Infrastructure.Secrets, 7.1.76"
                    
#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 Alvecta.Foundation.Infrastructure.Secrets@7.1.76
                    
#: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=Alvecta.Foundation.Infrastructure.Secrets&version=7.1.76
                    
Install as a Cake Addin
#tool nuget:?package=Alvecta.Foundation.Infrastructure.Secrets&version=7.1.76
                    
Install as a Cake Tool

Alvecta.Foundation.Infrastructure.Secrets

Keeps secrets out of configuration files: a configuration value written as secret:<name> is replaced at startup by the secret of that name, fetched from a pluggable secret store.

It belongs to the Infrastructure layer. Dependencies: Microsoft.Extensions.Configuration (+ .Abstractions). A store implementation comes separately; Alvecta.Foundation.Infrastructure.AmazonSsm provides one for AWS Systems Manager Parameter Store.

What it contains

  • ISecretProvider — GetSecretsAsync(IReadOnlySet<string> secretNames, CancellationToken) returns the value of every requested secret, keyed by name, in one round trip.
  • ResolveSecretsAsync(this IConfigurationManager, ISecretProvider, CancellationToken) — scans every configuration value for the secret: prefix (case-insensitive), fetches all the named secrets in a single call, and adds the plain values as an in-memory source on top. The last source wins, so every later reader of IConfiguration and of bound options sees the resolved value. A secret referenced by several keys is fetched once.

Usage

dotnet add package Alvecta.Foundation.Infrastructure.Secrets

Reference secrets by name in any configuration source (appsettings.json, environment variables, ...):

{
  "Payments": {
    "ApiKey": "secret:/Prod/Shop/PaymentsApiKey"
  }
}

Resolve them after all configuration sources are added and before the services read configuration:

using Alvecta.Foundation.Infrastructure.Secrets;

var builder = WebApplication.CreateBuilder(args);

await builder.Configuration.ResolveSecretsAsync(secretProvider, CancellationToken.None);

// builder.Configuration["Payments:ApiKey"] now holds the secret itself.

A store implements one method. For example, an in-memory store for local runs and tests:

public sealed class InMemorySecretProvider(IReadOnlyDictionary<string, string> secrets) : ISecretProvider
{
    public Task<IReadOnlyDictionary<string, string>> GetSecretsAsync(
        IReadOnlySet<string> secretNames,
        CancellationToken cancellationToken)
    {
        IReadOnlyDictionary<string, string> result = secretNames.ToDictionary(name => name, name => secrets[name]);

        return Task.FromResult(result);
    }
}

Every requested name must be in the result: a missing one throws a KeyNotFoundException during resolution.

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 (1)

Showing the top 1 NuGet packages that depend on Alvecta.Foundation.Infrastructure.Secrets:

Package Downloads
Alvecta.Foundation.Infrastructure.AmazonSsm

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.83 0 10/29/2026
9.0.82 0 10/29/2026
8.1.81 0 10/29/2026
8.0.80 68 10/28/2026
8.0.79 64 10/28/2026
8.0.78 69 10/28/2026
8.0.77 73 10/28/2026
7.1.76 79 10/27/2026
7.1.75 91 10/26/2026
7.0.74 90 10/26/2026
7.0.73 99 10/23/2026
7.0.72 96 10/23/2026
7.0.71 106 10/23/2026
7.0.70 98 10/22/2026
7.0.69 100 10/21/2026
7.0.68 87 10/21/2026
7.0.67 99 10/20/2026
7.0.66 88 10/19/2026
7.0.65 100 10/19/2026
6.3.64 89 10/19/2026
Loading failed