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§
- blocking
blocking - 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). - testing
testing - 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§
- AppRole
Auth - AppRole login (
POST auth/<mount>/login, default mountapprole). - AppRole
Options - Options of
Sys::create_app_role. Unset fields use the server defaults. - Auth
- Auth module; get it with
OpenBaoClient::auth. - Auth
Info - A token issued by a login or
create_token(theauthblock of a response). - Certificate
- An issued or signed certificate.
- Certificate
Info - Result of
Pki::read_certificate. - Create
KeyOptions - Optional settings of
Transit::create_key. - DataKey
- A generated data key.
- Data
KeyOptions - Options of
Transit::generate_data_key. - Database
- Database engine at one mount; get it with
OpenBaoClient::database. - Database
Connection Config - A database connection (
configure_connection). - Database
Role - A dynamic role (
create_role/read_role). - Encrypt
Options - Optional settings of encrypt, decrypt and rewrap.
- Hash
Options - Options of
Transit::hash. - Health
Response - Typed
sys/healthanswer ofSys::health. - Hmac
Options - Options of
Transit::hmac. - Issue
Options - Options of
Pki::issue_certificateandPki::sign_csr. - JwtAuth
- JWT/OIDC login with a JWT (
POST auth/<mount>/login, default mountjwt). - Kubernetes
Auth - Kubernetes login with the pod’s service-account JWT (
POST auth/<mount>/login, default mountkubernetes). The JWT is read fromjwt_pathat every login. - KvMetadata
- Metadata of a KV v2 key (all versions).
- KvMetadata
Options - Options of
write_metadata. Unset fields are left unchanged. - KvSecret
- A KV secret: its data and (KV v2) the version metadata.
- KvSecrets
Provider - The
SecretsProviderover an OpenBao KV mount. - KvV1
- KV version 1 at one mount (no versions, metadata or
cas; those calls fail withUNSUPPORTEDwithout a request). - KvV2
- KV version 2 at one mount.
- KvVersion
Metadata - Metadata of one KV v2 version.
- Leader
Status - HA leader (
leader). - Lease
- A leased secret such as dynamic database credentials.
- Lease
Info - Result of
LeaseManager::renew. - Lease
Lookup - Result of
LeaseManager::lookup. - Lease
Manager - Lease manager; get it with
OpenBaoClient::leases. Closing the client stops every managed lease (leases are not revoked). - Manage
Options - Options of
LeaseManager::manage. - Managed
Lease - A lease renewed in the background (
LeaseManager::manage). Clones share it. - Mount
Info - A secrets engine or auth method mount.
- Mount
Options - Options of
enable_secrets_engineandenable_auth_method. - Open
BaoClient - Async client for OpenBao. Cheap to clone (clones share one connection pool, the token and the background tasks).
- Open
BaoConfig - Immutable client configuration; build it with
OpenBaoConfig::builderorOpenBaoConfig::from_env.Debugoutput redacts every credential. - Open
BaoConfig Builder - 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. - Seal
Status - Seal state (
seal_statusand the testingunseal). - Secret
Id - A generated AppRole secret id.
- Secret
IdOptions - Options of
Sys::generate_secret_id. - Secret
Response - A full OpenBao response (the payload of an unwrapped token can be any API response).
- Secrets
Provider Options - Options of
OpenBaoClient::secrets_with. Unset fields fall back to the client config (kv_mount,secrets_path,value_field,kv_version). - Sign
Options - Options of
Transit::signandTransit::verify. - Sys
- System module; get it with
OpenBaoClient::sys. - Tidy
Options - Options of
Pki::tidy. - Tidy
Status - State of the current or last tidy run.
- Token
Auth - Uses an existing token: login sets it on the client and verifies it with
lookup-self. - Token
Create Options - Options of
Auth::create_token. Unset fields use the server defaults. - Token
Info - Properties of the current token (
lookup_self). - Token
Renewer - 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 callson_expire. Clones share the renewer. - Token
Renewer Options - Options of
Auth::start_renewer. - Transit
- Transit engine at one mount; get it with
OpenBaoClient::transit. - Transit
Batch Item - One input of a batch call:
plaintextfor encryption,ciphertextfor decryption. - Transit
Batch Result - One result of a batch call, in input order. A failed item carries
error; the call itself succeeds when only some items fail. - Transit
Ciphertext - A ciphertext (
vault:v<N>:...) with the key version that produced it. - Transit
Key - A transit key (returned by
read_keyand the key-changing calls). - Transit
KeyConfig - Settings changed by
Transit::update_key_config; unset fields stay unchanged. - Transit
KeyVersion - One version of a transit key.
- Transit
Signature - A signature (
vault:v<N>:...). - Userpass
Auth - Userpass login (
POST auth/<mount>/login/<username>, default mountuserpass). - Wrap
Info - A wrapping token.
- Wrap
Lookup - 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 toKvV1orKvV2; v2-only calls fail withUNSUPPORTEDon 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§
- Auth
Method - A way to obtain a token. Implemented by
TokenAuth,AppRoleAuth,UserpassAuth,JwtAuthandKubernetesAuth; custom methods can build onAuth::login_with.
Type Aliases§
- OnExpire
- Callback run once when the token expires for good.
- OnLease
Error - Callback receiving a renewal error.
- OnLease
Expire - Callback run exactly once when a managed lease expires.
- OnLease
Renew - Callback receiving a renewal result.
- OnRenew
- Callback receiving a renewed token.
- OnRenew
Error - Callback receiving a renewal error.
- Open
BaoError - Service-prefixed alias of
Error.