Samhammer.Configuration.Vault 8.0.0

dotnet add package Samhammer.Configuration.Vault --version 8.0.0
NuGet\Install-Package Samhammer.Configuration.Vault -Version 8.0.0
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="Samhammer.Configuration.Vault" Version="8.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Samhammer.Configuration.Vault --version 8.0.0
#r "nuget: Samhammer.Configuration.Vault, 8.0.0"
#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.
// Install Samhammer.Configuration.Vault as a Cake Addin
#addin nuget:?package=Samhammer.Configuration.Vault&version=8.0.0

// Install Samhammer.Configuration.Vault as a Cake Tool
#tool nuget:?package=Samhammer.Configuration.Vault&version=8.0.0

Samhammer.Configuration.Vault

This library can be used if you want to load specific keys from vault. This is done by configuring the vault key as value.

If you just need a specific vault folder to be added as section to your appsettings you can use this library instead: https://github.com/MrZoidberg/VaultSharp.Extensions.Configuration

How to add this to your project:

Example Program.cs:

var builder = WebApplication.CreateBuilder(args);

var vaultUrl = "https://myHashicorpVault.com";
var authMethodInfo = new TokenAuthMethodInfo(token);
var options = new VaultOptions();

builder.Host.ConfigureAppConfiguration(cb => cb.AddVault(new Uri(vaultUri), authMethodInfo, options));
builder.Services.AddHealthChecks().AddVault(new Uri(vaultUri), authMethodInfo);

There is also an overload of AddVault where you can directly add the VaultSharp client.

All auth methods of VaultSharp are supported. See docs for further details: https://github.com/rajanadar/VaultSharp

VaultOptions:

  • VaultKeyPrefix: Used as value prefix and prefix for the internally created setting keys, that contain the vault keys. The default is "VaultKey--".
  • ReloadInterval: If set, the reload from vault is enabled. Per default, the reload is disabled.
  • OmitMissingSecrets: Per default, an exception is thrown if a settings key is missing in vault. If set to true the value of the setting will be left empty for missing vault secrets.

Example appsettings configuration:

"MyOptions": {
  "Username": "MyUserNameValue",
  "Password": "MyCustomPrefix--kv-v2/data/myproject/myfolder/mysecret/Password",
  "PasswordTwo": "MyCustomPrefix--myproject/myfolder/mysecret/Password"
},

The first part has to be the prefix configured in VaultOptions or if nothing set "VaultKey--". The vault keys can be added with "kv-v2/data/" or without.

Remark: Internally there will be added additional settings keys that hold the vault key. The setting key names are prefixed with the VaultKeyPrefix. e.g. MyCustomPrefix--PasswordTwo. These settings are below the same parent key.

Watch for changes and get current value:

Use the IOptionsMonitor interface for that. IOptions is only initialized once.

You can find additional information here: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-7.0#options-interfaces

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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 Samhammer.Configuration.Vault:

Package Downloads
Samhammer.Configuration.Vault.Sag

Load configuration from hashicorp vault

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 122 3/8/2024
0.1.3 3,670 4/17/2023
0.1.2 444 3/30/2023
0.1.0 578 3/7/2023