#vault #hashi-corp #interact #session #mount #client

hc-vault

A simple crate to interact with hashicorp's vault

6 releases

0.3.0 Dec 21, 2020
0.2.3 Dec 19, 2020
0.1.0 Dec 7, 2020

#879 in Authentication

Download history 41/week @ 2024-07-28 2/week @ 2024-09-22 68/week @ 2024-10-13 95/week @ 2024-10-20 8/week @ 2024-11-03

171 downloads per month

MIT license

51KB
1K SLoC

hc-vault

A rust library to interact with hashicorp vault

Example

Obtaining a new Session using approle-auth

let vault_url = "http://localhost:8200".to_string();
let role_id = "example-role-id".to_string();
let secret_id = "example-secret-id".to_string();

// Obtaining an Auth session, in this cause using approle
let approle_auth = match hc_vault::approle::Session::new(role_id, secret_id) {
	Err(e) => {
		println!("{}", e);
		return;
	},
	Ok(a) => a,
};

let config = hc_vault::Config {
	vault_url: vault_url, // The client will use this vault url
	..Default::default() // Use the default values for everything else
};

// Obtaining a valid vault-session, 
// using the previously obtained Auth Session and config
let vault_client = match hc_vault::Client::new(config, approle_auth).await {
  Err(e) => {
    println!("{}", e);
    return;
  },
  Ok(c) => c,
};
// Use vault_client for whatever you need to do

lib.rs:

Async, highly concurrent crate to interact with vault and its mounts

Dependencies

~4–9MB
~166K SLoC