Skip to content

JoaoFranco91/JF91.VaultSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JF91.VaultSharp

WIP Minimalist Vault Client.

1: Install Nuget Package

dotnet add package JF91.VaultSharp

Available authentication methods:

  • Token
  • App Role

Available features:

  • Get all secrets from path
  • Get secret name value
  • Get secret name value and update appsettings.json

How to use:

Add this to your appsettings.json:

"VaultSettings": {
    "AuthenticationMethod": "approle",
    "Host": "http://localhost:8200",
    "RoleId": "",
    "SecretId": "",
    "Token": ""
}

Possible values:

  • AuthenticationMethod: approle, token

All methods are extensions methods from IConfiguration, which you can inject anywhere in your application and call them like this:

private readonly IConfiguration _configuration;

public MyController
(
    IConfiguration configuration
)
{
    _configuration = configuration;
}

[HttpGet(Name = "MyEndpoint")]
public ActionResult HelloWorld()
{
    var secrets = _configuration.GetVaultSecrets
    (
        "kv",
        "secretPath"
    );

    var secretValue = _configuration.GetVaultSecret
    (
        "kv",
        "secretPath",
        "secretName"
    );
    
    _configuration.InjectSecretToConfiguration
    (
        "kv",
        "test",
        "test2",
        "Secrets:Test",
        "Development" // Application Environment
    );
    
    _configuration.InjectSecretToConfiguration
    (
        "kv",
        "test",
        "test2",
        "Secrets:Nested:Test",
        "Development" // Application Environment
    );

    _configuration.InjectSecretToConfiguration
    (
        "kv",
        "test",
        "test2",
        "Secrets:Child[1]:Test",
        "Development" // Application Environment
    );

    return "Hello World!";
}

Releases

No releases published

Packages

No packages published

Languages