Tooark.Secrets.Vault 4.7.0

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

Tooark.Secrets.Vault

Tooark.Secrets provider on HashiCorp Vault and OpenBao: it loads the KV version 2 secrets into IConfiguration and implements ISecretService on them. OpenBao keeps the Vault API, so the same package serves both.

The client is the package's own, on the HTTP API, without a third-party library: it covers reading and listing the KV and authentication by token, AppRole or Kubernetes.

The model, the common options and the conversion of names into keys are in the Tooark.Secrets README. This README covers what is specific to Vault.

🌍 Languages: πŸ‡ΊπŸ‡Έ English (this file) Β· πŸ‡§πŸ‡· PortuguΓͺs


πŸ“‘ Contents


πŸ”§ Installation

dotnet add package Tooark.Secrets.Vault

βš™οΈ Configuration

appsettings.json

{
  "Secrets": {
    "Address": "https://vault.company.com:8200",
    "Path": "arkuest/prod",
    "AuthMethod": "Kubernetes",
    "Role": "arkuest"
  }
}

Program.cs

using Tooark.Secrets.Vault.Injections;

// KV secrets in the configuration, on top of appsettings.json
builder.Configuration.AddTooarkSecretsVault();

// Runtime secret reads, with cache
builder.Services.AddTooarkSecretsVault(builder.Configuration);

The IConfigurationBuilder AddTooarkSecretsVault requires Path. The IServiceCollection one registers ISecretService, which reads any KV path.

VaultSecretsOptions properties

Besides the common options:

Property Type Default Description
Address string? VAULT_ADDR/BAO_ADDR Store address. Required
Namespace string? VAULT_NAMESPACE/BAO_NAMESPACE Namespace, in Vault Enterprise or OpenBao
Mount string secret Mount path of the KV version 2
Path string? β€” KV path that becomes configuration, read recursively
AuthMethod string Token Token, AppRole or Kubernetes
AuthMount string? approle/kubernetes Mount path of the authentication method
Token string? VAULT_TOKEN/BAO_TOKEN Token, in the Token method
RoleId string? β€” Role ID, in the AppRole method
SecretId string? β€” Secret ID, in the AppRole method
Role string? β€” Store role, in the Kubernetes method
KubernetesTokenPath string pod service account token Token file read in the Kubernetes method

A missing address, token and namespace come from the command-line client's environment variables: first VAULT_*, then BAO_*. A value set in the configuration wins over them.


πŸ”‘ Authentication

Method When to use How it works
Kubernetes Application in a Kubernetes cluster The pod's service account token goes into the login; no secret in configuration
AppRole Machine, VM or pipeline Role ID in configuration and Secret ID delivered by the deployment environment
Token Development and tests The token goes straight into the requests, without login

The AppRole and Kubernetes token is obtained on first use. When the store rejects it, because it expired or was revoked, the client logs in again and repeats the request once. The Token method's token is not renewed.


πŸ”’ Access policy

The identity's policy needs to read the secrets and list the path's folders:

path "secret/data/arkuest/prod/*" {
  capabilities = ["read"]
}

path "secret/data/arkuest/prod" {
  capabilities = ["read"]
}

path "secret/metadata/arkuest/prod/*" {
  capabilities = ["list"]
}

path "secret/metadata/arkuest/prod" {
  capabilities = ["list"]
}

🧭 Behavior on Vault

  • One field, one key β€” the SecretKey field of the secret arkuest/prod/Storage becomes Storage:SecretKey; the fields of the secret at Path itself sit at the root.
  • Recursive read β€” Path is walked folder by folder, up to 10 levels. A path that is both a secret and a folder has both read.
  • JSON fields β€” a field's value stays as text, even when it is JSON, unless ExpandJson. A field that is not text (number, object) arrives in JSON format.
  • Current version β€” the current version of each secret applies; a deleted secret is skipped.
  • ISecretService β€” the name is the KV path, and the value is the JSON object with the fields; GetFieldAsync reads one field.

πŸ“‹ Dependencies

Package Version Description
Tooark.Secrets 4.x Model and configuration source
Microsoft.Extensions.DependencyInjection.Abstractions 8.x/10.x Container registration

There is no third-party client: the calls to the store use the .NET HttpClient.


⚠️ Error Codes and Solutions

The common errors are in the Tooark.Secrets README. A failure to load the source arrives as Secrets.LoadFailed;Vault, with the store error in InnerException.

Message Description Solution
Options.Secrets.Vault.AddressNotConfigured No address nor VAULT_ADDR/BAO_ADDR Configure Secrets:Address
Options.Secrets.Vault.AddressInvalid;{value} Address is not an absolute http or https URL Use the full address, with the port
Options.Secrets.Vault.AuthMethodInvalid;{value} Unknown authentication method Use Token, AppRole or Kubernetes
Options.Secrets.Vault.TokenNotConfigured Token method without a token nor VAULT_TOKEN Provide the token through the environment
Options.Secrets.Vault.AppRoleNotConfigured AppRole method without Role ID or Secret ID Provide both
Options.Secrets.Vault.KubernetesRoleNotConfigured Kubernetes method without Role Provide the role configured in the store
Secrets.Vault.LoginFailed The store rejected the login Check the role, the Role ID and the Secret ID
Secrets.Vault.KubernetesTokenNotFound;{path} The service account token does not exist Check automountServiceAccountToken and the path

🀝 Contributing

Contributions are welcome! Start with CONTRIBUTING.md β€” it covers the development workflow, the coding and commit conventions and the pull request checklist. Bugs and feature requests go through the issue templates of the Tooark repository.

By participating you agree to the Code of Conduct.


πŸ†˜ Help & Security

  • ❓ Questions, bugs, feature ideas β€” see SUPPORT.md for the right channel
  • πŸ”’ Security vulnerabilities β€” do not open a public issue; follow SECURITY.md

πŸ’– Support

If Tooark helps your projects, consider supporting its development:

Every contribution helps keep the project maintained and improving. Thank you! πŸ™


πŸ“„ License

This project is licensed under the BSD 3-Clause License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  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 is compatible.  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
4.7.0 95 9/30/2026