credentials icon indicating copy to clipboard operation
credentials copied to clipboard

Support KVv2 secrets engine

Open AlexTMjugador opened this issue 2 years ago • 0 comments

Vault secret storage is powered by a variety of secret engines. As asserted in source code comments of this crate, the specifics of the secrets format are not very well documented, but the official Go client mentions that the format of the data field is "up to the secret backend".

As a consequence of this, trying to use the secret engine KVv2 with this crate does not work because the data field format was changed, leading to deserialization errors in the Secret struct: KVv1, KVv2.

To address this in a straightforward way, let's allow secret data to be deserialized from either of the KVv1 or KVv2 formats. These formats have been tested successfully with the KVv1, KVv2, and Cubbyhole backends. Other backends may be potentially supported too, as long as they share a similar data format.

While at it, I have instructed serde to default deserializing a lease_duration of 0 in case that field is absent in the Secret response. Although I haven't encountered instances where this field is missing in real-world scenarios, the lack of comprehensive documentation (edit: and the explicit warning on the API documentation about how there might be breaking changes even within the v1 API version) prompts a defensive approach, assuming the least possible about the response format.

AlexTMjugador avatar Jan 09 '24 12:01 AlexTMjugador