Skip to main content

Typed HashiCorp Vault KV helper library with pragmatic auth and env helpers.

Project description

vault-kv-client

vault-kv-client is a small, typed, and production-friendly helper library for working with HashiCorp Vault KV engines through hvac.

It focuses on the common parts teams end up re-implementing around Vault:

  • KV v1 and v2 support with automatic mount version detection
  • Token, AppRole, Kubernetes, and Vault JWT/OIDC authentication
  • Enterprise namespace support
  • Recursive listing and secret copy helpers
  • Optional in-memory read caching
  • Environment-driven bootstrap for CI, Kubernetes, and legacy Airflow deployments

Installation

pip install vault-kv-client

With uv:

uv add vault-kv-client

With Poetry:

poetry add vault-kv-client

Quick Start

from vault_kv_client import VaultAuth, VaultManager, VaultSettings

settings = VaultSettings(
    addr="https://vault.example.com",
    verify=True,
    namespace=None,
)

auth = VaultAuth(token="s.xxxxx")
client = VaultManager(settings=settings, auth=auth)

secret = client.get_secret("kv", "apps/my-service")
print(secret["username"])

Environment-driven bootstrap is also available:

from vault_kv_client import get_default_manager

client = get_default_manager()
secret = client.get_secret("kv", "apps/my-service")

Public API

Root package exports:

  • VaultManager
  • VaultSettings
  • VaultAuth
  • VaultJWTAuth
  • VaultKubernetesAuth
  • VaultClientError
  • VaultNotConfiguredError
  • VaultDependencyError
  • SecretNotFoundError
  • get_default_manager()
  • get_creds()

Core methods:

  • get_secret(mount_point, path, kv_version=None)
  • upsert_secret(mount_point=..., path=..., secret=..., kv_version=None)
  • list_secrets(mount_point, path="", kv_version=None)
  • list_all_secrets(mount_point, path="", kv_version=None)
  • copy_secret(source_mount=..., target_mount=..., path=...)
  • clear_cache()

Authentication Modes

The library supports four mutually exclusive auth modes:

  • token
  • approle
  • kubernetes
  • jwt

Full examples are documented in docs/auth-methods.md.

Legacy Compatibility

The historical package name vault_client is still shipped as a temporary compatibility layer:

from vault_client import VaultManager

That import path now emits a DeprecationWarning. New projects should use vault_kv_client.

Documentation

Repository docs are designed for self-service onboarding:

The GitHub Pages site is generated from the same sources via MkDocs Material.

Development

python3 -m venv .venv
. .venv/bin/activate
pip install -U pip uv
uv pip install -e ".[dev]"
ruff check .
mypy src
pytest -q
mkdocs build

Security

  • Never log secret payloads.
  • Prefer short-lived auth flows where possible.
  • Use the minimum Vault policy scope required for your application.
  • Report security issues through the process described in SECURITY.md.

License

This project is licensed under the Apache License 2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vault_kv_client-0.1.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vault_kv_client-0.1.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file vault_kv_client-0.1.0.tar.gz.

File metadata

  • Download URL: vault_kv_client-0.1.0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for vault_kv_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e7e5598eb73641da7f6ca778ae31acb355aea796ec33c0bb50711b48e34c751a
MD5 73cf13e7937541f6bf46c9561c889fdd
BLAKE2b-256 52c661d5fa893066f7d1408d495d376b1fa8cca618545512eff68ce553391a68

See more details on using hashes here.

File details

Details for the file vault_kv_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vault_kv_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cbbee03db68f33d93a900b9809e30854699a2bab712c6052e1864d8c038b76ce
MD5 fc4bad8060834a6781d833eb57f0d025
BLAKE2b-256 50fa6221b9dd0ae41da1bd878f4a20bf41490e167e3cf24d45d8f3daf5a83da6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page