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 tokenrefresh_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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file naturalis_vault-0.2.0.tar.gz.
File metadata
- Download URL: naturalis_vault-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
345be8ee54f56221f20ca56ad7a2b605ecdfd8c940846367025ae41dd2eea9dc
|
|
| MD5 |
abc7bb2a38d578c604aa839e9228999c
|
|
| BLAKE2b-256 |
4b8bd3b68e6441a14c3466c8b03569fadbb771674434b7e1653e163bf4709f2c
|
File details
Details for the file naturalis_vault-0.2.0-py3-none-any.whl.
File metadata
- Download URL: naturalis_vault-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d895ac0abac66ecf0901971f36e6e9f4e34690eb35c856550774a7dd27a9eb6
|
|
| MD5 |
8401291fe42e99a2d81f8bcf46a8ce7f
|
|
| BLAKE2b-256 |
5181c3fdb600eaea3ce0ad43b4d9040a7d78f1a2292b454deac66126757108b8
|