jmgilman / vaultrs

An asynchronous Rust client library for the Hashicorp Vault API
https://docs.rs/vaultrs
MIT License
97 stars 60 forks source link

Adds support for using wrapping token as client token #2

Closed nhey closed 3 years ago

nhey commented 3 years ago

in order to unwrap said token without authenticating first.

From the sys/wrapping/unwrap api docs (https://www.vaultproject.io/api-docs/system/wrapping-unwrap#wrapping-unwrap):

This endpoint can be used by using a wrapping token as the client token in the API call, in which case the token parameter is not required [...]. Do not use the wrapping token in both locations; this will cause the wrapping token to be revoked but the value to be unable to be looked up, as it will basically be a double-use of the token!

I have tested that it works. Should I add a test case to the cargo tests?

jmgilman commented 3 years ago

I agree that having the Option<> better matches the way the API describes usage. Are you just setting the token when you create the client and then calling unwrap? I don't think this needs a separate test case since you'd effectively just be testing Vault at that point (testing the token is sent in the request header is already tested numerous times by the other tests).

nhey commented 3 years ago

Yes, that is exactly what I am doing. In that case I will leave the PR as it is for your review.