Vault.NET is an .NET API client for the interacting with Vault. This is a port of the go api client and provides generic methods for interacting with the paths in Vault.
usingVault;varvaultClient=newVaultClient();vaultClient.Token="XXXXXX";vardata=newDictionary<string,string>{{"zip","zap"}};awaitvaultClient.Secret.Write("secret/foo",data);varsecret=awaitvaultClient.Secret.Read<Dictionary<string,string>>("secret/foo");Console.WriteLine(secret.Data["zip"]);// zapusingVault.Models.Secret.Pki;vartestRole=newRolesRequest{AllowAnyDomain=true,EnforceHostnames=false,MaxTtl="1h"};awaitvaultClient.Secret.Write("pki/roles/test",testRole);varcertRequest=newIssueRequest{CommonName="Test Cert"};varcert=awaitvaultClient.Secret.Write<IssueRequest,IssueResponse>("pki/issue/test",certRequest);Console.WriteLine(secret.Data.Certificate);// -----BEGIN CERTIFICATE-----// MII...usingVault.Models.Auth.UserPass;awaitvaultClient.Sys.EnableAuth("userpass","userpass","Userpass Mount");varusersRequest=newUsersRequest{Password="password",Policies=newList<string>{"default"},Ttl="1h",MaxTtl="2h"};awaitvaultClient.Auth.Write("userpass/users/username",usersRequest);varloginRequest=newLoginRequest{Password="password"};varloginResponse=awaitvaultClient.Auth.Write<LoginRequest,NoData>("userpass/login/username",loginRequest);// Set client token to authenticated tokenvaultClient.Token=loginResponse.Auth.ClientToken;// Proceed with authenticated requestsMany request/response objects are provided in this package to support different backends. This is in no way an exhaustive list of all the objects. Since the models are the things that are going to most likely change between versions of vault, it may make sense to make your own to service your needs. These may get split into a seperate Nuget package in the future.
Since most of the operation of this library are just building requests and passing them to the vault API and the vault team provides an easy to use local development server, each test runs against its own vault server. This means that tests require the vault binary available to spin up the vault server instance. The test suite will first look for the environment variable VAULT_BIN and if not found will fall back to use the vault binary in the $PATH.
Downloads for vault can be found here.
This library will follow the version of vault that it was developed against. Since most core operations of vault maintain backwards compatibility, this library can be used against many older and newer versions of vault. If features are added or bugs are fixed, a new point release will be created (ex. 0.6.4 -> 0.6.4.1). If there is some functionality that breaks on a newer version of vault, please submit a pull request.