Dosaic.Plugins.Persistence.VaultSharp 1.1.11

dotnet add package Dosaic.Plugins.Persistence.VaultSharp --version 1.1.11
                    
NuGet\Install-Package Dosaic.Plugins.Persistence.VaultSharp -Version 1.1.11
                    
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="Dosaic.Plugins.Persistence.VaultSharp" Version="1.1.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dosaic.Plugins.Persistence.VaultSharp" Version="1.1.11" />
                    
Directory.Packages.props
<PackageReference Include="Dosaic.Plugins.Persistence.VaultSharp" />
                    
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 Dosaic.Plugins.Persistence.VaultSharp --version 1.1.11
                    
#r "nuget: Dosaic.Plugins.Persistence.VaultSharp, 1.1.11"
                    
#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 Dosaic.Plugins.Persistence.VaultSharp@1.1.11
                    
#: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=Dosaic.Plugins.Persistence.VaultSharp&version=1.1.11
                    
Install as a Cake Addin
#tool nuget:?package=Dosaic.Plugins.Persistence.VaultSharp&version=1.1.11
                    
Install as a Cake Tool

Dosaic.Plugins.Persistence.VaultSharp

Dosaic.Plugins.Persistence.VaultSharp is a plugin that allows other Dosaic components to interact with HashiCorp Vault for secure secret storage.

Installation

To install the nuget package follow these steps:

dotnet add package Dosaic.Plugins.Persistence.VaultSharp

or add as package reference to your .csproj

<PackageReference Include="Dosaic.Plugins.Persistence.VaultSharp" Version=""/>

Appsettings.yml

Configure your appsettings.yml with these properties:

vault:
  url: "http://localhost:8200"
  token: "your-vault-token"
  totpIssuer: "myissuer" # optional, default is Dosaic.Plugins.Persistence.VaultSharp
  totpPeriodInSeconds: 30 # optional, default is 30 seconds

Registration and Configuration

Secret Storage

To use the secret storage functionality, first define an enum for your secret buckets e.g.:

public enum SecretBucket
{
    ApiKeys = 0,
    DatabaseCredentials = 1,
    UserSecrets = 2
}

Then register the secret storage for your bucket enum:

services.AddSecretStorage<SecretBucket>();

This registers ISecretStorage<SecretBucket> which can be injected into your services.

Basic setup without a dosaic web host (optional)

If you don't use the dosaic webhost, which automatically configures the DI container, you'll need to register the VaultSharp plugin manually:

services.AddVaultSharpPlugin(new VaultConfiguration
{
    Url = "http://localhost:8200",
    Token = "your-vault-token"
    TotpIssuer = "myissuer", // optional, default is Dosaic.Plugins.Persistence.VaultSharp
    TotpPeriodInSeconds = 30 // optional, default is 30 seconds
});

Working with Secrets

Example of using the secret storage interface:

public class SecretProvider(ISecretStorage<SecretBucket> secretStorage)
{
    public async Task<Secret> GetSecretAsync(SecretId<SecretBucket> secretId, CancellationToken cancellationToken = default)
    {
        return await secretStorage.GetSecretAsync(secretId, cancellationToken);
    }

    public async Task<SecretId<SecretBucket>> CreateSecretAsync(SecretBucket bucket, Secret secret, CancellationToken cancellationToken = default)
    {
        return await secretStorage.CreateSecretAsync(bucket, secret, cancellationToken);
    }

    public async Task<SecretId<SecretBucket>> UpdateSecretAsync(SecretId<SecretBucket> secretId, Secret secret, CancellationToken cancellationToken = default)
    {
        return await secretStorage.UpdateSecretAsync(secretId, secret, cancellationToken);
    }

    public async Task DeleteSecretAsync(SecretId<SecretBucket> secretId, CancellationToken cancellationToken = default)
    {
        await secretStorage.DeleteSecretAsync(secretId, cancellationToken);
    }
}

Health Checks

The VaultSharp plugin automatically configures a readiness health check that verifies connectivity with the Vault server. This ensures your application doesn't start until it can securely access secrets.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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.1.11 84 7/18/2025
1.1.10 80 7/18/2025
1.1.9 143 7/8/2025
1.1.8 139 7/7/2025
1.1.7 223 6/13/2025
1.1.6 146 6/5/2025
1.1.5 142 6/4/2025
1.1.4 137 6/4/2025
1.1.3 128 5/23/2025
1.1.2 151 5/8/2025
1.1.1 147 5/6/2025
1.1.0 106 5/2/2025