rajanadar / VaultSharp

A comprehensive cross-platform .NET Library for HashiCorp's Vault, a secret management tool
http://rajanadar.github.io/VaultSharp
Apache License 2.0
488 stars 130 forks source link

How to read the root token and use it to call Vault APIs? #324

Closed apetrut closed 1 week ago

apetrut commented 1 year ago

Hi,

I am trying to read the root token in a secure way using ReadSecretAsync but without passing the root token in the IAuthMethod.

AuthMethodInfo authMethod = new TokenAuthMethodInfo("123456789");
var vaultClientSettings = new VaultClientSettings("http://127.0.0.1:8200", authMethod);
var vaultClient = new VaultClient(vaultClientSettings);

var secret = await vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync("auth/token/root");
var rootToken = secret.Data.Data["token"];

Is there a way to do that programatically and secure?

rajanadar commented 1 week ago

@apetrut That's not a valid use case. KV Secret is used to store your own secrets. Root token is a starting point and you need to have access.