Crate config_vault

Crate config_vault 

Source
Expand description

§config-vault

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

This library implements a custom Source for the config crate that can connect to a HashiCorp Vault server and load secrets from the KV2 engine 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
);

Structs§

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

Enums§

KvVersion