Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add vault support #1

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
vault_client dependency replaced with ureq
  • Loading branch information
soleinik-figment committed Oct 20, 2022
commit ecc748bae8567c6a2427d29ae7edcb04a7999346
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ yubihsm = { version = "0.41", features = ["secp256k1", "setup", "usb"], optional
zeroize = "1"



# HashiCorp deps
ureq = { version = "~2.5", default-features=false, features = ["tls", "json", "gzip"], optional = true}
base64 = { version = "0.13.0", optional = true}
aes-kw = { version = "0.2.1", features = ["std"], optional = true}
Expand Down
1 change: 0 additions & 1 deletion src/keyring/providers/hashicorp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pub(crate) mod client;
pub(crate) mod error;
pub(crate) mod signer;
pub(crate) mod vault_data;

use crate::{
chain,
Expand Down
27 changes: 22 additions & 5 deletions src/keyring/providers/hashicorp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use std::collections::{BTreeMap, HashMap};

use super::error::Error;

use super::vault_data;

use std::time::Duration;
use ureq::Agent;

use serde::{Deserialize, Serialize};
use serde_json::Value;

pub const CONSENUS_KEY_TYPE: &str = "ed25519";
const VAULT_TOKEN: &str = "X-Vault-Token";
Expand All @@ -25,6 +24,24 @@ pub(crate) struct TendermintValidatorApp {
#[allow(unsafe_code)]
unsafe impl Send for TendermintValidatorApp {}

///Vault message envelop
#[derive(Default, Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Root<T> {
#[serde(rename = "request_id")]
pub request_id: String,
#[serde(rename = "lease_id")]
pub lease_id: String,
pub renewable: bool,
#[serde(rename = "lease_duration")]
pub lease_duration: i64,
pub data: Option<T>,
#[serde(rename = "wrap_info")]
pub wrap_info: Value,
pub warnings: Value,
pub auth: Value,
}

///Sign Request Struct
#[derive(Debug, Serialize)]
struct SignRequest {
Expand Down Expand Up @@ -173,7 +190,7 @@ impl TendermintValidatorApp {
))
.set(VAULT_TOKEN, &self.token)
.call()?
.into_json::<vault_data::Root<PublicKeyResponse>>()?
.into_json::<Root<PublicKeyResponse>>()?
.data
{
data
Expand Down Expand Up @@ -257,7 +274,7 @@ impl TendermintValidatorApp {
))
.set(VAULT_TOKEN, &self.token)
.send_json(body)?
.into_json::<vault_data::Root<SignResponse>>()?
.into_json::<Root<SignResponse>>()?
.data
{
data
Expand Down Expand Up @@ -308,7 +325,7 @@ impl TendermintValidatorApp {
.get(&format!("{}/v1/transit/wrapping_key", self.api_endpoint))
.set(VAULT_TOKEN, &self.token)
.call()?
.into_json::<vault_data::Root<PublicKeyResponse>>()?
.into_json::<Root<PublicKeyResponse>>()?
.data
{
data
Expand Down
52 changes: 0 additions & 52 deletions src/keyring/providers/hashicorp/vault_data.rs

This file was deleted.