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
493 stars 134 forks source link

Can we get the vaultToken from Vault sharp #166

Closed mohanakrishnans007 closed 3 years ago

mohanakrishnans007 commented 3 years ago

Hi , I have a requirement of retrieving the vaultToken , preserving it in cache for a time limit in order to avoid multiple calls to Vault to fetch secret. Is there a way I can retrieve the vault token using VaultSharp?

I am using the below version of Vault Sharp Package package id="VaultSharp" version="1.4.0.5" targetFramework="net452"

Thanks! Mohan

rajanadar commented 3 years ago

Yes the fetched vault token is made available by VaultSharp here.

https://github.com/rajanadar/VaultSharp/blob/master/src/VaultSharp/V1/AuthMethods/IAuthMethodInfo.cs#L22

You can access the ReturnedLoginAuthInfo to see the vault token that VaultSharp generated based on your login method.

Also note that, if you make million calls using VaultSharp to read secrets, VaultSharp makes only 1 call to get the vault token. It fetches it just once and then internally reuses it for the other million calls. (it uses a lazy variable internally to do this)