pvNugsSecretManagerNc10ProviderEnvironment 10.0.0
dotnet add package pvNugsSecretManagerNc10ProviderEnvironment --version 10.0.0
NuGet\Install-Package pvNugsSecretManagerNc10ProviderEnvironment -Version 10.0.0
<PackageReference Include="pvNugsSecretManagerNc10ProviderEnvironment" Version="10.0.0" />
<PackageVersion Include="pvNugsSecretManagerNc10ProviderEnvironment" Version="10.0.0" />
<PackageReference Include="pvNugsSecretManagerNc10ProviderEnvironment" />
paket add pvNugsSecretManagerNc10ProviderEnvironment --version 10.0.0
#r "nuget: pvNugsSecretManagerNc10ProviderEnvironment, 10.0.0"
#:package pvNugsSecretManagerNc10ProviderEnvironment@10.0.0
#addin nuget:?package=pvNugsSecretManagerNc10ProviderEnvironment&version=10.0.0
#tool nuget:?package=pvNugsSecretManagerNc10ProviderEnvironment&version=10.0.0
๐ pvNugsSecretManagerNc10ProviderEnvironment
Environment Variable and Configuration provider for the pvWay Secret Manager stack on .NET 10. ๐
This package implements IPvNugsSecretProvider and retrieves secrets from any source supported by Microsoft.Extensions.Configuration, including environment variables, appsettings.json, user secrets, and command-line arguments.
This package is intended to be used together with:
pvNugsSecretManagerNc10for orchestration, caching, and exception normalization- an application-defined
IPvNugsSecretManagerconsumer such as acallerService
๐๏ธ Architecture
The current design is intentionally split into three layers:
- Caller service / application code injects
IPvNugsSecretManager - Secret manager package (
pvNugsSecretManagerNc10) orchestrates calls, caching, and logging - Provider package (
pvNugsSecretManagerNc10ProviderEnvironment) reads from configuration sources So the main application typically registers both:
IPvNugsSecretManagerviaPvNugsSecretManagerDi.TryAddPvNugsSecretManager(...)- one concrete
IPvNugsSecretProvider, hereEnvVarSecretProviderviaPvNugsEnvVarSecretProviderDi.TryAddPvNugsEnvVarSecretProvider(...)
๐ค Caller service
โ injects
๐ IPvNugsSecretManager
โ delegates to
๐ EnvVarSecretProvider
โ reads from
โ๏ธ Configuration Sources
(Environment Variables, appsettings.json, User Secrets, etc.)
โจ Features
- ๐ Retrieves secrets from environment variables, JSON files, user secrets, command-line args, and more
- ๐ Optional prefix support for organizing secrets into namespaces
- ๐ง DI-friendly registration
- โก Lightweight and fast - no external service calls
- ๐งช Perfect for development and testing scenarios
- โ ๏ธ Explicit unsupported-feature behavior for batch and dynamic secret APIs
โ Supported behavior
- โ๏ธ
GetStaticSecretAsync(...)retrieves one secret by the canonical parameter keysecretName - โ
GetStaticSecretsAsync(...)is not supported and throwsPvNugsEnvVarProviderException - โ
GetDynamicSecretAsync(...)is not supported and throwsPvNugsEnvVarProviderExceptionEnvironment variables and configuration files are static by nature and do not support dynamic credential rotation or batch secret retrieval like HashiCorp Vault.
๐ฆ Installation
Install-Package pvNugsSecretManagerNc10ProviderEnvironment
Or with the .NET CLI:
dotnet add package pvNugsSecretManagerNc10ProviderEnvironment
๐ Dependencies
This package depends on:
Microsoft.Extensions.Options.ConfigurationExtensionspvNugsLoggerNc10AbstractionspvNugsSecretManagerNc10AbstractionsThe application that uses this provider should also reference:pvNugsSecretManagerNc10- one cache implementation and one logger implementation required by the secret manager package
โ๏ธ Configuration
๐จ SECURITY BEST PRACTICE
The JSON examples below are for illustrative purposes only. In production environments:
- NEVER commit actual secrets to appsettings.json files
- ALWAYS use environment variables for real production secrets
- JSON files should only contain placeholders or configuration structure
- Use
.gitignoreto exclude any local development configuration files with secrets
The provider is bound from the PvNugsEnvVarSecretProviderConfig section.
๐ Without prefix (root-level secrets)
{
"PvNugsEnvVarSecretProviderConfig": {
"Prefix": null
},
// โ ๏ธ WARNING: These are EXAMPLES ONLY - never commit real secrets!
"DatabasePassword": "REPLACE-WITH-ENV-VAR",
"ApiKey": "REPLACE-WITH-ENV-VAR"
}
โ RECOMMENDED - Set environment variables directly:
# Windows
set DatabasePassword=my-dev-password
set ApiKey=my-dev-api-key
# Linux/macOS
export DatabasePassword=my-dev-password
export ApiKey=my-dev-api-key
๐ With prefix (organized secrets)
{
"PvNugsEnvVarSecretProviderConfig": {
"Prefix": "MyApp"
},
"MyApp": {
// โ ๏ธ WARNING: These are EXAMPLES ONLY - never commit real secrets!
"DatabasePassword": "REPLACE-WITH-ENV-VAR",
"ApiKey": "REPLACE-WITH-ENV-VAR"
}
}
โ RECOMMENDED - Set environment variables with hierarchical naming:
# Windows
set MyApp__DatabasePassword=my-dev-password
set MyApp__ApiKey=my-dev-api-key
# Linux/macOS
export MyApp__DatabasePassword=my-dev-password
export MyApp__ApiKey=my-dev-api-key
๐ง Multi-environment configuration
Leverage .NET's environment-specific configuration files:
appsettings.Development.json (local development only - DO NOT COMMIT with real secrets):
{
"PvNugsEnvVarSecretProviderConfig": {
"Prefix": "MyApp_Dev"
},
"MyApp_Dev": {
// โ ๏ธ For local dev only - use User Secrets or local env vars
"DatabasePassword": "local-dev-only",
"ApiKey": "local-dev-only"
}
}
appsettings.Production.json (โ BEST PRACTICE - no secrets in file):
{
"PvNugsEnvVarSecretProviderConfig": {
"Prefix": "MyApp_Prod"
}
// โ
CORRECT: Secrets come from environment variables in production
// โ
NEVER include actual secret values in this file
// โ
Set environment variables:
// MyApp_Prod__DatabasePassword=<real-secret>
// MyApp_Prod__ApiKey=<real-secret>
}
๐ง Service registration
using pvNugsSecretManagerNc10;
using pvNugsSecretManagerNc10Abstractions;
using pvNugsSecretManagerNc10ProviderEnvironment;
var builder = WebApplication.CreateBuilder(args);
// Register the provider first
builder.Services.TryAddPvNugsEnvVarSecretProvider(builder.Configuration);
// Register the provider-agnostic manager
builder.Services.TryAddPvNugsSecretManager(builder.Configuration);
var app = builder.Build();
๐ก Usage
Your caller service should depend on IPvNugsSecretManager, not on the provider directly.
You can use the helper PvNugsEnvVarSecretProviderParameters.CreateParameters(...)
to avoid repeating dictionary boilerplate.
using pvNugsSecretManagerNc10Abstractions;
using pvNugsSecretManagerNc10ProviderEnvironment;
public class CallerService(IPvNugsSecretManager secretManager)
{
public async Task<string?> GetDatabasePasswordAsync(CancellationToken ct = default)
{
var parameters = PvNugsEnvVarSecretProviderParameters
.CreateParameters("DatabasePassword");
return await secretManager.GetStaticSecretAsync(parameters, ct);
}
public async Task<string?> GetApiKeyAsync(CancellationToken ct = default)
{
var parameters = PvNugsEnvVarSecretProviderParameters
.CreateParameters("ApiKey");
return await secretManager.GetStaticSecretAsync(parameters, ct);
}
}
๐ Parameter contract
The canonical key for single-secret retrieval is:
PvNugsEnvVarSecretProviderParameters.SecretName // "secretName"
The key is intentionally explicit so callers can build the dictionary once and reuse it consistently. Helper available:
PvNugsEnvVarSecretProviderParameters.CreateParameters("DatabasePassword")
The helper validates input and returns a read-only dictionary containing the canonical
"secretName" key/value pair.
๐ Configuration precedence
The provider follows standard .NET configuration precedence (last wins):
- appsettings.json (lowest priority)
- appsettings.{Environment}.json
- User secrets (development only)
- Environment variables
- Command-line arguments (highest priority) This means environment variables will override values from appsettings.json.
๐ก Use cases
โ Perfect for:
- ๐งช Development and testing - Quick setup without external dependencies
- ๐ณ Container deployments - Inject secrets via environment variables
- ๐ User Secrets - Local development with sensitive data
- โก Simple applications - No need for complex secret management infrastructure
- ๐ Provider fallback - Graceful degradation when external secret services are unavailable
โ ๏ธ Not recommended for:
- ๐ Dynamic credentials - Use Azure provider or HashiCorp Vault for rotating credentials
- ๐ข Enterprise production - Consider Azure Key Vault, AWS Secrets Manager, or HashiCorp Vault
- ๐ฆ Batch secret retrieval - This provider only supports single-secret access
โ ๏ธ Notes on unsupported APIs
This provider does not support:
- Secret dictionaries by mount/path
- Dynamic database credential generation
- Secret rotation or expiration
Unsupported operations fail fast with
PvNugsEnvVarProviderExceptionso callers can handle the limitation explicitly.
๐ Security considerations
โ CRITICAL: Never Commit Secrets to Version Control
This is the #1 security rule when using this provider:
- โ NEVER store real secrets in
appsettings.json,appsettings.Production.json, or ANY file under version control - โ NEVER commit files containing actual passwords, API keys, connection strings, or tokens to Git
- โ NEVER store production secrets in configuration files that could be accidentally exposed
โ RECOMMENDED Secret Storage Methods
For Production Environments:
Environment Variables (Primary recommendation for this provider)
- Set at the operating system level
- Injected by deployment platform (Azure App Service, Kubernetes, Docker, etc.)
- Never stored in files or version control
Azure Key Vault Provider (Recommended for enterprise)
- Use
pvNugsSecretManagerNc10ProviderAzureinstead of this provider - Proper secret rotation and auditing
- Better for production environments
- Use
For Development Environments:
User Secrets (
dotnet user-secrets)- Stored outside project directory
- Automatically excluded from source control
- Only for local development
Local Environment Variables
- Set in your development machine
- Not committed to version control
๐ณ Container & Cloud Deployment Best Practices
- Containers (Docker/Kubernetes): Inject secrets via environment variables or mounted volumes
- Azure App Service: Use App Settings (environment variables) or Key Vault references
- AWS: Use Systems Manager Parameter Store or Secrets Manager
- Cloud platforms: Use platform-native secret injection mechanisms
๐ Configuration File Guidelines
If you must use JSON configuration files:
โ DO:
- Store only non-sensitive configuration
- Use placeholder values like
"REPLACE-WITH-ENV-VAR"or"SET-VIA-ENVIRONMENT" - Document which values need to be set via environment variables
- Add
appsettings.*.local.jsonto.gitignore
โ DON'T:
- Store any production secrets
- Commit local development files with real credentials
- Share configuration files containing sensitive data
๐จ If Secrets Are Accidentally Committed
If you accidentally commit secrets to version control:
- Immediately rotate all exposed secrets
- Do NOT just delete the file and commit - the secret is still in Git history
- Consider the secret permanently compromised
- Use tools like
git-secretsortruffleHogto scan repositories - Review your repository's entire Git history
๐ Additional Security Measures
- Principle of Least Privilege: Only grant access to secrets that are absolutely necessary
- Regular Rotation: Change secrets periodically even if not compromised
- Monitoring: Log secret access attempts and investigate anomalies
- Encryption at Rest: Ensure storage systems encrypt data
- CI/CD Secrets: Use GitHub Secrets, Azure DevOps Variable Groups, or similar secure storage
๐ฆ Recommended package split
pvNugsSecretManagerNc10Abstractions: interfacespvNugsSecretManagerNc10: caching, logging, orchestrationpvNugsSecretManagerNc10ProviderEnvironment: Environment Variable / Configuration providerpvNugsSecretManagerNc10ProviderAzure: Azure Key Vault provider (for production)
๐ Related packages
- pvNugsSecretManagerNc10 - Core secret manager orchestration
- pvNugsSecretManagerNc10ProviderAzure - Azure Key Vault provider
- pvNugsCacheNc10Memory - In-memory cache implementation
- pvNugsLoggerNc10 - Logging abstractions
๐ License
MIT โ see LICENSE.
โ ๏ธ CRITICAL SECURITY WARNING
DO NOT store actual secrets in appsettings.json or any files under version control!
This provider should primarily use ENVIRONMENT VARIABLES for production secrets. While it can read from JSON configuration files, those should only contain non-sensitive configuration or be used for local development with placeholder values.
โ RECOMMENDED: Environment variables, User Secrets (dev only), Azure Key Vault
โ NEVER: Real secrets in appsettings.json files committed to Git/source control
| 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.Options.ConfigurationExtensions (>= 10.0.9)
- pvNugsLoggerNc10Abstractions (>= 10.0.0)
- pvNugsSecretManagerNc10Abstractions (>= 10.0.0)
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 |
|---|---|---|
| 10.0.0 | 115 | 6/21/2026 |
Fix missing config provisioning