Skip to main content

OpenBao Vault wrapper for token generation and secret retrieval

Project description

naturalis-vault

OpenBao Vault client library for Naturalis.

  • Vault: reads secrets from Vault KV v2, given a token
  • refresh_vault_token: obtains a token via OIDC authentication

The library never writes tokens or secrets to your filesystem. Token persistence is up to the caller.

Installation

uv add naturalis-vault

Usage

from naturalis.vault import Vault, refresh_vault_token

# Obtain a token (opens browser for OIDC login)
token = refresh_vault_token(server_url="https://vault.naturalis.io")

# Use it
vault = Vault(
    secret_path="team/project/production",
    token=token,
)

api_key = vault.get_secret("IMPORTANT_API_KEY")

To avoid having to log in on every run, store the token yourself (e.g. in an environment variable) and pass it directly:

vault = Vault(
    server_url="https://vault.naturalis.io",
    secret_path="team/project/production",
    token=os.getenv("VAULT_TOKEN"),
)

Or even monitor the token's last refresh date and regenerate it automatically:

today = str(date.today())
token = os.getenv("VAULT_TOKEN")

# Consider the vault token to be fresh if it was last refreshed today
if not os.getenv("VAULT_TOKEN_LAST_REFRESH") == today and token:
    token = refresh_vault_token(server_url="https://vault.naturalis.io")

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

naturalis_vault-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

naturalis_vault-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: naturalis_vault-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for naturalis_vault-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f8af21b92f68e44450f5df51162b219914bea512d35584c533e3b546c7ab3aa
MD5 40e40cf2032a5e5864385b45cf29c849
BLAKE2b-256 874d397bc977a7e20799b47a6148fae826c97967e3e5905a75b6b8b66e658244

See more details on using hashes here.

File details

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

File metadata

  • Download URL: naturalis_vault-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for naturalis_vault-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0839eb4602b3625689428602944e98b7d55e517bf924bff92c158b491c73ca5c
MD5 1c9fee492de8568d9b7509291c52e906
BLAKE2b-256 6b3cee572bede4d4bfe9c20ef88069685abccdab1a7eb85eb15ada149a7fc4dc

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