Alvecta.Foundation.Infrastructure.Secrets
6.3.64
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
<PackageReference Include="Alvecta.Foundation.Infrastructure.Secrets" Version="6.3.64" />
<PackageVersion Include="Alvecta.Foundation.Infrastructure.Secrets" Version="6.3.64" />
<PackageReference Include="Alvecta.Foundation.Infrastructure.Secrets" />
paket add Alvecta.Foundation.Infrastructure.Secrets --version 6.3.64
#r "nuget: Alvecta.Foundation.Infrastructure.Secrets, 6.3.64"
#:package Alvecta.Foundation.Infrastructure.Secrets@6.3.64
#addin nuget:?package=Alvecta.Foundation.Infrastructure.Secrets&version=6.3.64
#tool nuget:?package=Alvecta.Foundation.Infrastructure.Secrets&version=6.3.64
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 thesecret: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 ofIConfigurationand 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 | 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.Configuration (>= 10.0.13)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.13)
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 |