Devies.Extensions.HashiCorpVault
An eisting vault
A client_token or any auth path in the vault
Any IBuilderConfiguration with values set to vaild vault values
Install the nuget package dotnet add package Devies.Extensions.HashiCorpVault
Login and get a token with VaultUtils.LoginWithUserpass or VaultUtils.LoginWithK8SServiceAccount, or your own way.
Call AddVaultEnvironments on your IConfigurationBuilder with your vault-url and token
AddVaultEnvironments HAS TO BE AFTER all other settings that may involve vault variables
appsettings.Development.json
{
"ServiceOptions" : {
"Url" : " https://service.org" ,
"Username" : " vault:secret/data/service/dev#username" ,
"Password" : " vault:secret/data/service/dev#userpass"
}
}
private Func < IConfigurationBuilder , string , IConfigurationRoot > ConfigurationBuilder =
( builder , vaultToken ) =>
builder . SetBasePath ( Directory . GetCurrentDirectory ( ) )
. AddJsonFile ( "appsettings.Development.json" )
. AddVaultEnvironments ( "https://vault.myorg.org" , vaultToken )
. Build ( ) ;