Alvecta.Foundation.Infrastructure.Secrets 6.3.64

There is a newer version of this package available.
See the version list below for details.
dotnet add package Alvecta.Foundation.Infrastructure.Secrets --version 6.3.64
                    
NuGet\Install-Package Alvecta.Foundation.Infrastructure.Secrets -Version 6.3.64
                    
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="6.3.64" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Alvecta.Foundation.Infrastructure.Secrets" Version="6.3.64" />
                    
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 6.3.64
                    
#r "nuget: Alvecta.Foundation.Infrastructure.Secrets, 6.3.64"
                    
#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@6.3.64
                    
#: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=6.3.64
                    
Install as a Cake Addin
#tool nuget:?package=Alvecta.Foundation.Infrastructure.Secrets&version=6.3.64
                    
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
7.0.67 0 10/20/2026
7.0.66 0 10/19/2026
7.0.65 0 10/19/2026
6.3.64 7 10/19/2026
6.3.63 5 10/19/2026
6.2.62 109 10/14/2026
6.1.61 90 10/9/2026
6.1.60 99 10/7/2026
6.1.59 95 10/6/2026
6.1.58 98 10/5/2026
6.0.57 103 10/2/2026
6.0.56 92 10/1/2026
6.0.55 99 10/1/2026
5.0.54 105 9/30/2026
5.0.53 106 9/28/2026
5.0.52 110 9/17/2026
5.0.51 108 9/17/2026
5.0.50 105 9/17/2026
5.0.49 108 9/17/2026
5.0.48 98 9/17/2026
Loading failed