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.VaultSharpor 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 secondsRegistration and Configuration
Secret Storage
To use the secret storage functionality, first define an enum for your secret buckets e.g.:
Then register the secret storage for your bucket enum:
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:
Working with Secrets
Example of using the secret storage interface:
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.
Last updated
