Crate config_vault_source

Crate config_vault_source 

Source
Expand description

§config-vault-source

config-vault-source is an extension for the config crate that allows loading configurations directly from HashiCorp Vault.

Source code of config-vault-source is pretty similar as in parent crate config-vault but with support of tls, async and nested configuration keys.

This library implements a custom Source or AsyncSource via async feature for the config crate that can connect to a HashiCorp Vault server and load secrets from the KV1/KV2 engines as configuration values.

§Example

use config::{Config, ConfigError};
use config_vault::VaultSource;

fn load_config() -> Result<Config, ConfigError> {
    let vault_source = VaultSource::new(
        "http://127.0.0.1:8200".to_string(),  // Vault address
        "hvs.EXAMPLE_TOKEN".to_string(),      // Vault token
        "secret".to_string(),                 // KV mount name
        "dev".to_string(),        // Secret path
    );

    Config::builder()
        .add_source(vault_source)
        // You can add other sources
        .build()
}

If you want to use the KV1 engine, you can use the new_v1 method instead of new:

use config_vault::VaultSource;

let vault_source = VaultSource::new_v1(
        "http://127.0.0.1:8200".to_string(),  // Vault address
        "hvs.EXAMPLE_TOKEN".to_string(),      // Vault token
        "secret".to_string(),                 // KV mount name
        "dev".to_string(),        // Secret path
);

Re-exports§

pub use builder::VaultSourceBuilder;

Modules§

builder

Structs§

VaultAddr
VaultConfig
VaultSource
A Source for the config library that loads configurations from HashiCorp Vault.

Enums§

KvVersion