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 across different sessions is up to the user.

Installation

# UV
uv add naturalis-vault

# pip
pip install naturalis-vault

Usage

from naturalis.vault import Vault, refresh_vault_token

# Obtain a token (opens browser for OIDC login)
token = refresh_vault_token()

# Retrieve a secret
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. The package automatically retrieves the VAULT_TOKEN environment variable if it was set.

vault = Vault(
    secret_path="team/project/production",
)

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

import os
from datetime import date

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

# Consider the vault token to be fresh if it was last refreshed today
if os.getenv("VAULT_TOKEN_LAST_REFRESH") != today and token:
    token = refresh_vault_token()
    os.environ["VAULT_TOKEN"] = token
    os.environ["VAULT_TOKEN_LAST_REFRESH"] = today

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.3.1.tar.gz (3.6 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.3.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: naturalis_vault-0.3.1.tar.gz
  • Upload date:
  • Size: 3.6 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.3.1.tar.gz
Algorithm Hash digest
SHA256 4da7546a289be3c1d7611343b544da64c8ae5d003a44b4b600557a5cfb961a50
MD5 c6fcae3b9a614b268a5dd4352a0b1f78
BLAKE2b-256 a9fec91e002f985dd55be6510d357ecb75b9f8ec583988fc17a00fa11a9f19f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: naturalis_vault-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 09e68717b9d13fe31bffcaf7fd4d9f101455c1e450384579c24fb0d94f84ea3e
MD5 bcc26750a972836340ab8b72696192ef
BLAKE2b-256 e013fe64ab0b4771fbd5fb2c3a85692668a6af3486a3a669598df8966617fb35

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