Voyager.Configuration.MountPath 2.4.1-preview.4

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

Voyager.Configuration.MountPath

NuGet License

An ASP.NET Core extension for organizing JSON configuration files with support for environment-specific settings, encrypted values, and Docker/Kubernetes mount paths.

About

This library provides a simple way to organize JSON configuration files by file name (without extensions) and load them conditionally based on environment variables. Designed for containerized environments like Docker and Kubernetes, it allows you to:

  • Organize configuration by concern: Separate files for database, logging, services, etc.
  • Load files conditionally: Automatically loads environment-specific variants (e.g., database.json + database.Production.json)
  • Mount at runtime: Keep configuration outside container images using volume mounts
  • Update without rebuilding: Change configuration without rebuilding or redeploying

Built-in AES-256-GCM encryption โ€” sensitive configuration values are decrypted in-memory at the IConfiguration level. Plaintext never touches disk, protecting secrets from AI agents, IDE indexers, and OS-level backups. See Encrypting Configuration below.

Features

  • ๐Ÿ“ File-based organization: Pass file names (without extensions) as parameters
  • ๐ŸŽฏ Conditional loading: Automatic environment-based file selection
  • ๐Ÿณ Container-friendly: Mount configuration from external volumes
  • ๐Ÿ”„ Hot reload: Automatically reload when configuration files change
  • ๐Ÿ”Œ Dependency Injection: Full DI support with interfaces
  • ๐Ÿ—๏ธ SOLID architecture: Interface-based design for testability
  • ๐Ÿ“ฆ Multi-targeting: Supports .NET 4.8, .NET Core 3.1, .NET 6.0, and .NET 8.0

Installation

dotnet add package Voyager.Configuration.MountPath

Quick Start

Basic Usage: Single Configuration File

Pass file names (without .json extension) as parameters:

using Microsoft.Extensions.DependencyInjection;

var builder = Host.CreateDefaultBuilder(args);

builder.ConfigureAppConfiguration((context, config) =>
{
    var provider = context.HostingEnvironment.GetSettingsProvider();

    // Loads: appsettings.json + appsettings.{Environment}.json
    config.AddMountConfiguration(provider, "appsettings");
});

File structure:

YourApp/
โ”œโ”€โ”€ bin/
โ”‚   โ””โ”€โ”€ config/
โ”‚       โ”œโ”€โ”€ appsettings.json           # Base configuration
โ”‚       โ””โ”€โ”€ appsettings.Production.json # Environment-specific overrides

How it works:

  1. Loads base file: appsettings.json (required)
  2. Loads environment file: appsettings.{ASPNETCORE_ENVIRONMENT}.json (optional by default)
  3. Environment-specific values override base values

Customizing Settings

Configure custom mount paths or require environment-specific files:

builder.ConfigureAppConfiguration((context, config) =>
{
    config.AddMountConfiguration(settings =>
    {
        settings.FileName = "myconfig";           // File name without extension
        settings.ConfigMountPath = "configuration"; // Default: "config"
        settings.HostingName = "Production";      // Override environment detection
        settings.Optional = false;                // Require environment file
    });
});

Require environment-specific file:

builder.ConfigureAppConfiguration((context, config) =>
{
    // Throws exception if appsettings.Production.json doesn't exist
    config.AddMountConfiguration(context.HostingEnvironment.GetSettingsProviderForce());
});

Organizing Configuration by Concern

The key feature: organize configuration into separate files by concern, each loaded conditionally based on environment:

builder.ConfigureAppConfiguration((context, config) =>
{
    var provider = context.HostingEnvironment.GetSettingsProvider();

    // Each file name is loaded as: {name}.json + {name}.{Environment}.json
    config.AddMountConfiguration(provider, "appsettings");  // App settings
    config.AddMountConfiguration(provider, "database");     // Database config
    config.AddMountConfiguration(provider, "logging");      // Logging config
    config.AddMountConfiguration(provider, "services");     // External services
});

File structure:

config/
โ”œโ”€โ”€ appsettings.json
โ”œโ”€โ”€ appsettings.Production.json
โ”œโ”€โ”€ database.json
โ”œโ”€โ”€ database.Production.json
โ”œโ”€โ”€ logging.json
โ”œโ”€โ”€ logging.Production.json
โ”œโ”€โ”€ services.json
โ””โ”€โ”€ services.Production.json

Benefits:

  • Separation of concerns: Each file handles one aspect of configuration
  • Conditional loading: Different values for Development, Production, Staging, etc.
  • Easier management: Update only relevant files without touching others

Docker and Kubernetes Examples

Docker Example

Mount configuration files at runtime to separate concerns:

Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY bin/Release/net8.0/publish .

# Configuration will be mounted at runtime
ENTRYPOINT ["dotnet", "YourApp.dll"]

docker-compose.yml:

services:
  myapp:
    image: myapp:latest
    volumes:
      - ./config:/app/config:ro  # Mount config folder
    environment:
      - ASPNETCORE_ENVIRONMENT=Production

config/ directory:

config/
โ”œโ”€โ”€ database.json              # Base database config
โ”œโ”€โ”€ database.Production.json   # Production overrides
โ”œโ”€โ”€ logging.json               # Base logging config
โ””โ”€โ”€ logging.Production.json    # Production logging settings

Kubernetes Example

Use ConfigMaps for different configuration concerns:

database-config.yaml:

apiVersion: v1
kind: ConfigMap
metadata:
  name: database-config
data:
  database.json: |
    {
      "ConnectionStrings": {
        "Default": "Server=db;Database=myapp;..."
      }
    }

logging-config.yaml:

apiVersion: v1
kind: ConfigMap
metadata:
  name: logging-config
data:
  logging.json: |
    {
      "Logging": {
        "LogLevel": {
          "Default": "Information"
        }
      }
    }

deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  template:
    spec:
      containers:
      - name: myapp
        image: myapp:latest
        volumeMounts:
        - name: database-config
          mountPath: /app/config/database.json
          subPath: database.json
        - name: logging-config
          mountPath: /app/config/logging.json
          subPath: logging.json
      volumes:
      - name: database-config
        configMap:
          name: database-config
      - name: logging-config
        configMap:
          name: logging-config

Dependency Injection

Register configuration services:

// Register settings provider
builder.Services.AddVoyagerConfiguration();

// Register custom settings provider
builder.Services.AddVoyagerConfiguration<MyCustomSettingsProvider>();

// Use in your services
public class MyService
{
    private readonly ISettingsProvider _settingsProvider;

    public MyService(ISettingsProvider settingsProvider)
    {
        _settingsProvider = settingsProvider;
    }
}

Advanced Usage

Custom Settings Provider

Implement ISettingsProvider for custom behavior:

public class MySettingsProvider : ISettingsProvider
{
    public Settings GetSettings(string filename = "appsettings")
    {
        return new Settings
        {
            FileName = filename,
            ConfigMountPath = "/custom/path",
            HostingName = "Production"
        };
    }
}

// Register in DI
builder.Services.AddVoyagerConfiguration<MySettingsProvider>();

Encrypting Configuration

Voyager.Configuration.MountPath provides built-in AES-256-GCM encryption for sensitive configuration values. Plaintext never touches disk โ€” decryption happens in-memory at the IConfiguration level, protecting secrets from AI agents, IDE indexers, swap files, and backups.

1. Generate an encryption key:

dotnet tool install -g Voyager.Configuration.Tool
vconfig keygen
# โ†’ yK3vM9pQ+L2nR5sT8wXaB1cD4eF7gH0iJ2kL3mN4oP8=
#
# Save this value in ASPNETCORE_ENCODEKEY.
# Anyone with this key can decrypt your configuration.

2. Set the key as an environment variable:

export ASPNETCORE_ENCODEKEY="yK3vM9pQ+L2nR5sT8wXaB1cD4eF7gH0iJ2kL3mN4oP8="

3. Encrypt a configuration file:

vconfig encrypt --input config/secrets.json --in-place

Encrypted values are stored in the v2: format (v2:BASE64(nonce||ciphertext||tag)). Non-string values (numbers, booleans) are preserved unchanged.

4. Load encrypted configuration at runtime:

builder.ConfigureAppConfiguration((context, config) =>
{
    var provider = context.HostingEnvironment.GetSettingsProvider();
    var encryptionKey = Environment.GetEnvironmentVariable("ASPNETCORE_ENCODEKEY");

    config.AddMountConfiguration(provider, "logging");
    config.AddMountConfiguration(provider, "appsettings");

    // Encrypted files โ€” decrypted in-memory, plaintext never on disk
    config.AddEncryptedMountConfiguration(encryptionKey, provider, "secrets");
    config.AddEncryptedMountConfiguration(encryptionKey, provider, "connectionstrings");
});

Migrating from legacy DES encryption:

If you have files encrypted with the older DES-based encryption, migrate to AES-256-GCM:

# Generate new AES key
export ASPNETCORE_AES_KEY=$(vconfig keygen)

# Re-encrypt (DES values โ†’ AES, already-AES values untouched)
vconfig reencrypt --input config/secrets.json \
  --legacy-key-env ASPNETCORE_ENCODEKEY \
  --new-key-env ASPNETCORE_AES_KEY

# Swap keys in deployment, then remove old DES key

See ADR-010 for the full encryption design, threat model, and migration plan.

Security Considerations

Why in-memory decryption matters

Modern development environments include AI coding agents (Claude Code, Copilot, Cursor) with broad filesystem read access. A plaintext secrets file on disk is readable by agents, indexed by IDEs, captured by swap files and backups โ€” without any audit trail.

Voyager's approach: encrypted values in JSON files on disk, decrypted in memory at IConfiguration level. Plaintext never touches the filesystem. This is a stronger security property than tools that decrypt to disk (e.g. sops -d file.json > plain.json).

Encryption โ€” AES-256-GCM

  • Algorithm: AES-256-GCM with 12-byte random nonce and 16-byte authentication tag per value
  • Integrity: Wrong key or tampered ciphertext always throws โ€” never silent garbage
  • In-memory decryption: Plaintext stays off disk, protecting against AI agents, IDE indexers, and OS-level backups
  • Legacy DES support: Existing DES-encrypted files are readable during migration (AllowLegacyDes=true in v2.x, planned removal in v4.x)

Best Practices

  1. Key management: Store the AES key in environment variables or a secret manager โ€” never in source code
  2. File permissions: Ensure configuration files have appropriate read permissions
  3. Container security: Mount configuration volumes as read-only (:ro)
  4. Migration: Run vconfig reencrypt to migrate legacy DES files to AES-256-GCM
  5. Extension point: IEncryptor / IEncryptorFactory allow custom encryption implementations if needed

Architecture

This library follows SOLID principles and modern .NET design patterns:

  • Single Responsibility Principle: Each class has one well-defined responsibility
  • Interface-based design: IEncryptor, ISettingsProvider, ICipherProvider, IEncryptorFactory
  • Dependency Injection: Full support for DI container registration
  • Extension methods: Organized by responsibility for better maintainability

Extension Methods Organization

The library provides extension methods organized by their specific concerns:

  • ConfigurationExtension: Non-encrypted mount configuration
  • EncryptedMountConfigurationExtensions: Encrypted mount configuration (high-level API)
  • EncryptedJsonFileExtensions: Encrypted JSON file operations (low-level API)
  • ServiceCollectionExtensions: Dependency injection registration

All extension methods are placed in the Microsoft.Extensions.DependencyInjection namespace following .NET conventions.

Note: The ConfigurationEncryptedExtension class is deprecated and will be removed in version 3.0. Use EncryptedMountConfigurationExtensions and EncryptedJsonFileExtensions instead.

Documentation

Migration Guide

For migration from version 1.x to 2.x, see Migration Guide.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

See also the list of contributors who participated in this project.

Acknowledgements

  • Przemysล‚aw Wrรณbel - Icon design
  • All contributors who have helped improve this library

Support

If you encounter any issues or have suggestions:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net48 is compatible.  net481 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
2.5.0 102 4/29/2026
2.4.2-preview.1.2 52 4/29/2026
2.4.2-preview.1 49 4/29/2026
2.4.1 93 4/29/2026
2.4.1-preview.5 46 4/29/2026
2.4.1-preview.4 48 4/29/2026
2.4.1-preview.3 58 4/29/2026
2.4.1-preview.2 53 4/29/2026
2.4.0 92 4/28/2026
2.3.0-preview.1.1 53 4/28/2026
2.3.0-preview.1 48 4/20/2026
2.2.1-preview.6 50 4/20/2026
2.2.1-preview.5 74 4/20/2026
2.2.1-preview.4 49 4/16/2026
2.2.0 110 4/16/2026
2.1.1-preview.3 49 4/15/2026
2.1.1-preview.2 50 4/15/2026
2.1.1-preview.1 57 4/15/2026
2.1.0 104 4/15/2026
2.0.1-preview.2 53 4/15/2026
Loading failed

AES-256-GCM encryption (ADR-010) replaces DES as the default cipher. Includes versioned ciphertext format (v2: prefix), BouncyCastle polyfill for .NET Framework 4.8, and backward-compatible legacy DES reads. See CHANGELOG.md for details.