MSHelper.Secrets.Vault 1.0.0

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

// Install MSHelper.Secrets.Vault as a Cake Tool
#tool nuget:?package=MSHelper.Secrets.Vault&version=1.0.0                

MSHelper.Secrets.Vault : Secure configuration using Vault.

⭐ Star us on GitHub � it motivates us a lot!

Vault

Adds the secured and centralized configuration storage integration using Vault.

Installation

This document is for the latest MSHelper.Secrets.Vault 1.0.0 release and later.

dotnet add package MSHelper.Secrets.Vault

Dependencies

-- MSHelper

Usage

Extend Program.cs → CreateDefaultBuilder() with UseVault() that will add the required services and fetch the options from Vault key-value secret storage during an application startup.

public static IWebHostBuilder GetWebHostBuilder(string[] args)
    => WebHost.CreateDefaultBuilder(args)
        .ConfigureServices(services => services.AddMSHelper().Build())
        .UseVault();

Options

--- enabled - determines whether Vault integration is going to be available.

--- url - URL of the Vault service.

--- authType - authentication type, possible values: token, userpass.

--- token - a secret token used to authenticate to Vault, used when authType = token.

--- username - name of the user used to authenticate to Vault, used when authType = userpass.

--- password - password of the user used to authenticate to Vault, used when authType = userpass.

--- kv - KV storage used for loading JSON settings during application startup.

appsettings.json

"vault": {
  "enabled": true,
  "url": "http://localhost:8200",
  "authType": "token",
  "token": "secret",
  "username": "user",
  "password": "secret",
  "kv": {
    "enabled": true,
    "engineVersion": 2,
    "mountPoint": "kv",
    "path": "some-service/settings"
  },
  "pki": {
    "enabled": true,
    "roleName": "some-service",
    "commonName": "some-service.some-app.io"
  },
  "lease": {
    "mongo": {
      "type": "database",
      "roleName": "some-service",
      "enabled": true,
      "autoRenewal": true,
      "templates": {
        "connectionString": "mongodb://:@localhost:27017"
      }
    }
  }
}

Beware that storing the secret token or other type of credentials used while authenticating to Vault during an application startup in appsettings.json file is not really secure. Instead, you should set these values by using e.g. environment variables when deploying your services to the server/cloud - such scenario can be done in a numerous ways, either by CI/CD tools or even with the usage of manual deployment.

Each setting within the appsettings.json file can be overriden with a proper environment variable. You can also override Vault settings with the following (custom) environment variables:

-- VAULT_URL

-- VAULT_KEY

-- VAULT_AUTH_TYPE

-- VAULT_TOKEN

-- VAULT_USERNAME

-- VAULT_PASSWORD

Important Note:

All the MSHelper packages are for self learning purposes inspired by Devmentors.io

Product Compatible and additional computed target framework versions.
.NET 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 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. 
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
1.0.0 225 10/25/2022