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.0.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.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: naturalis_vault-0.3.0.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.0.tar.gz
Algorithm Hash digest
SHA256 5dc09a99f4eb281382ff7d7db0f0e0d100fd046cd8ddb26f6c05588cfc2d03ab
MD5 084db4738c049eae4e1adf91c6a90cb7
BLAKE2b-256 df302db6ca56f726db21eb2954f149c877d745791ab997b4461246aced5a132d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: naturalis_vault-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4a0308296780ba458db67b01d626c16885d66fc6a5543fa69b67314c0543a9b
MD5 c323dcd2cf61a3b78912e2d6f92badbc
BLAKE2b-256 78f7f7f99ad8198f9c96add11a3aa9b8484ab7c8e9f5adb4ae7082c70970b074

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