Skip to main content

Crate grow_openbao

Crate grow_openbao 

Source
Expand description

§grow-openbao

Rust SDK for OpenBao by Grow Codes: one async client (tokio) for auth, KV v1/v2, transit, dynamic database credentials with a lease manager, PKI, policies and mounts, response wrapping and the Grow SecretsProvider over KV.

use grow_openbao::secrets::SecretsProvider;
use grow_openbao::{OpenBaoClient, OpenBaoConfig};

// explicit > GROW_OPENBAO_* > BAO_* / VAULT_* > defaults
let client = OpenBaoClient::new(OpenBaoConfig::from_env()?)?;
println!("healthy: {}", client.health().await?.healthy);

// KV v2 (auto-detected per mount)
let kv = client.kv().await?;
kv.write("app/db", serde_json::json!({"password": "s3cr3t"}), None).await?;
let secret = kv.read("app/db", None).await?;
assert_eq!(secret.data["password"], "s3cr3t");

// transit
let ct = client.transit().encrypt("app-key", b"hello", None).await?;
let pt = client.transit().decrypt("app-key", &ct.ciphertext, None).await?;
assert_eq!(pt, b"hello");

// the Grow SecretsProvider over KV
let secrets = client.secrets();
secrets.set("api-key", "abc123".into(), None).await?;
assert_eq!(secrets.get_string("api-key", None).await?.as_deref(), Some("abc123"));

client.close().await;

Features: blocking (a blocking client), testing (in-memory fakes, the conformance runner and the testing::init / testing::unseal server lifecycle helpers).

Re-exports§

pub use crate::core::Error;
pub use crate::core::ErrorCode;
pub use crate::core::HealthStatus;
pub use crate::core::Result;
pub use crate::core::RetryPolicy;
pub use crate::core::Secret;

Modules§

blockingblocking
Blocking wrapper (feature blocking). Each client owns a tokio runtime with one worker thread, so background work (lease renewal, secret watchers, retries’ timers) keeps running between blocking calls.
core
Shared core: errors, configuration, secrets in config, redaction, retries and transport.
secrets
Secrets category: values, provider traits, cache, watch and load_env (SPEC §3).
testingtesting
Test support (feature testing): in-memory fakes, the conformance runner (SPEC §6) and the OpenBao server lifecycle helpers (testing::init, testing::unseal, testing::seal, testing::init_status, testing::wait_for_active) used by test fixtures and bootstrap scripts.

Structs§

AppRoleAuth
AppRole login (POST auth/<mount>/login, default mount approle).
AppRoleOptions
Options of Sys::create_app_role. Unset fields use the server defaults.
Auth
Auth module; get it with OpenBaoClient::auth.
AuthInfo
A token issued by a login or create_token (the auth block of a response).
Certificate
An issued or signed certificate.
CertificateInfo
Result of Pki::read_certificate.
CreateKeyOptions
Optional settings of Transit::create_key.
DataKey
A generated data key.
DataKeyOptions
Options of Transit::generate_data_key.
Database
Database engine at one mount; get it with OpenBaoClient::database.
DatabaseConnectionConfig
A database connection (configure_connection).
DatabaseRole
A dynamic role (create_role / read_role).
EncryptOptions
Optional settings of encrypt, decrypt and rewrap.
HashOptions
Options of Transit::hash.
HealthResponse
Typed sys/health answer of Sys::health.
HmacOptions
Options of Transit::hmac.
IssueOptions
Options of Pki::issue_certificate and Pki::sign_csr.
JwtAuth
JWT/OIDC login with a JWT (POST auth/<mount>/login, default mount jwt).
KubernetesAuth
Kubernetes login with the pod’s service-account JWT (POST auth/<mount>/login, default mount kubernetes). The JWT is read from jwt_path at every login.
KvMetadata
Metadata of a KV v2 key (all versions).
KvMetadataOptions
Options of write_metadata. Unset fields are left unchanged.
KvSecret
A KV secret: its data and (KV v2) the version metadata.
KvSecretsProvider
The SecretsProvider over an OpenBao KV mount.
KvV1
KV version 1 at one mount (no versions, metadata or cas; those calls fail with UNSUPPORTED without a request).
KvV2
KV version 2 at one mount.
KvVersionMetadata
Metadata of one KV v2 version.
LeaderStatus
HA leader (leader).
Lease
A leased secret such as dynamic database credentials.
LeaseInfo
Result of LeaseManager::renew.
LeaseLookup
Result of LeaseManager::lookup.
LeaseManager
Lease manager; get it with OpenBaoClient::leases. Closing the client stops every managed lease (leases are not revoked).
ManageOptions
Options of LeaseManager::manage.
ManagedLease
A lease renewed in the background (LeaseManager::manage). Clones share it.
MountInfo
A secrets engine or auth method mount.
MountOptions
Options of enable_secrets_engine and enable_auth_method.
OpenBaoClient
Async client for OpenBao. Cheap to clone (clones share one connection pool, the token and the background tasks).
OpenBaoConfig
Immutable client configuration; build it with OpenBaoConfig::builder or OpenBaoConfig::from_env. Debug output redacts every credential.
OpenBaoConfigBuilder
Builder for OpenBaoConfig. Values set here win over the environment.
Pki
PKI engine at one mount; get it with OpenBaoClient::pki.
Policy
An ACL policy.
Revocation
Result of Pki::revoke_certificate.
SealStatus
Seal state (seal_status and the testing unseal).
SecretId
A generated AppRole secret id.
SecretIdOptions
Options of Sys::generate_secret_id.
SecretResponse
A full OpenBao response (the payload of an unwrapped token can be any API response).
SecretsProviderOptions
Options of OpenBaoClient::secrets_with. Unset fields fall back to the client config (kv_mount, secrets_path, value_field, kv_version).
SignOptions
Options of Transit::sign and Transit::verify.
Sys
System module; get it with OpenBaoClient::sys.
TidyOptions
Options of Pki::tidy.
TidyStatus
State of the current or last tidy run.
TokenAuth
Uses an existing token: login sets it on the client and verifies it with lookup-self.
TokenCreateOptions
Options of Auth::create_token. Unset fields use the server defaults.
TokenInfo
Properties of the current token (lookup_self).
TokenRenewer
Keeps the client token alive: renews at 2/3 of the remaining TTL, stops renewing when the token is not renewable or the max TTL caps the grant, then re-logs in (TokenRenewerOptions::relogin) or calls on_expire. Clones share the renewer.
TokenRenewerOptions
Options of Auth::start_renewer.
Transit
Transit engine at one mount; get it with OpenBaoClient::transit.
TransitBatchItem
One input of a batch call: plaintext for encryption, ciphertext for decryption.
TransitBatchResult
One result of a batch call, in input order. A failed item carries error; the call itself succeeds when only some items fail.
TransitCiphertext
A ciphertext (vault:v<N>:...) with the key version that produced it.
TransitKey
A transit key (returned by read_key and the key-changing calls).
TransitKeyConfig
Settings changed by Transit::update_key_config; unset fields stay unchanged.
TransitKeyVersion
One version of a transit key.
TransitSignature
A signature (vault:v<N>:...).
UserpassAuth
Userpass login (POST auth/<mount>/login/<username>, default mount userpass).
WrapInfo
A wrapping token.
WrapLookup
Result of Wrapping::lookup_wrapping.
Wrapping
Response-wrapping module; get it with OpenBaoClient::wrapping.

Enums§

Kv
A KV mount whose version was detected (OpenBaoClient::kv). Every method dispatches to KvV1 or KvV2; v2-only calls fail with UNSUPPORTED on v1.

Constants§

DEFAULT_KUBERNETES_JWT_PATH
Default path of the Kubernetes service-account token.
DEFAULT_KV_MOUNT
KV mount used by the secrets provider when none is configured.
DEFAULT_URL
Endpoint used when neither the builder nor the environment sets one.
DEFAULT_VALUE_FIELD
KV data field that holds a secrets-provider value.

Traits§

AuthMethod
A way to obtain a token. Implemented by TokenAuth, AppRoleAuth, UserpassAuth, JwtAuth and KubernetesAuth; custom methods can build on Auth::login_with.

Type Aliases§

OnExpire
Callback run once when the token expires for good.
OnLeaseError
Callback receiving a renewal error.
OnLeaseExpire
Callback run exactly once when a managed lease expires.
OnLeaseRenew
Callback receiving a renewal result.
OnRenew
Callback receiving a renewed token.
OnRenewError
Callback receiving a renewal error.
OpenBaoError
Service-prefixed alias of Error.