Skip to main content

Locke — Python

Unified credentials framework — encrypted config, OS keystore, Vaultwarden and OpenBao integration.

Install

For local development from this repository:

cd python
pip install -e ".[dev]"

From the repository root on macOS, install the public Locke CLI/package locally:

python3 -m pip install -e ./python
locke --version

The locke executable is installed into the active Python environment's bin directory, so make sure that directory is on your PATH.

Usage

Library

import locke

# Load and decrypt config → flat env vars
env = locke.load_config(".locke/config.encrypted.json")
# env["MONGO_URI"], env["SENTRY_DSN"], etc.

# Resolve a single credential
cred = locke.resolve_credential("LOCKE_ENCRYPTION_KEY")

# Get or set a vault secret
secret = locke.get_vault_secret("myproject/staging/api_key")
locke.set_vault_secret("myproject/staging/api_key", "new-value")

# Check Locke-owned setup placeholders ("FILL_ME")
if locke.is_placeholder(secret):
    raise RuntimeError("vault secret still needs a real value")

CLI

# Decrypt + flatten → shell exports
eval $(locke env)

# Decrypt to stdout
locke decrypt

# Encrypt plaintext config
locke encrypt

# Manage OS keystore
locke keystore set LOCKE_ENCRYPTION_KEY --prompt
locke keystore get LOCKE_ENCRYPTION_KEY

# Get vault secret
locke vault get myproject/staging/api_key

# Create missing vault entries from locke.json, then fill them interactively
locke vault setup
locke vault setup --interactive

# Get/set an OpenBao KV secret
locke openbao get myproject/staging/api_key
locke openbao set myproject/staging/api_key --password "new-value"

# Initialize project
locke init --project myproject --tenant staging

OpenBao KV

Locke can also read/write secrets from an OpenBao KV v1/v2 mount, using the same shape as the Vaultwarden client (get_secret/set_secret, get_secret_pair/set_secret_pair):

secret = locke.get_openbao_secret("myproject/staging/api_key")
locke.set_openbao_secret("myproject/staging/api_key", "new-value")

Connects via LOCKE_OPENBAO_ADDR/OPENBAO_ADDR/VAULT_ADDR and LOCKE_OPENBAO_TOKEN/OPENBAO_TOKEN/VAULT_TOKEN. See locke/openbao.py for the full env var list (mount, KV version).

Vault placeholders

Locke uses locke.PLACEHOLDER_VALUE ("FILL_ME") for vault entries that are known but not filled yet. Use locke.is_placeholder(value) instead of hard-coding the sentinel. VaultClient.get_secret() warns when it returns a placeholder; VaultClient.set_secret(path, None) or an empty value writes a placeholder and warns.

Environment Variables

Variable Purpose
LOCKE_ENV Override environment detection
LOCKE_ENCRYPTION_KEY Encryption key (if not in keystore)
LOCKE_USE_BIOMETRIC Set false to disable biometric gating
LOCKE_VAULT_URL Vaultwarden server URL
LOCKE_VAULT_USERNAME Vaultwarden username
LOCKE_OPENBAO_ADDR OpenBao server URL (falls back to OPENBAO_ADDR/VAULT_ADDR)
LOCKE_OPENBAO_TOKEN OpenBao token (falls back to OPENBAO_TOKEN/VAULT_TOKEN)

Testing

cd python
pip install -e ".[dev]"
pytest

Download files

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

Source Distribution

locke-0.9.0.tar.gz (94.7 kB view details)

Uploaded Source

Built Distribution

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

locke-0.9.0-py3-none-any.whl (61.6 kB view details)

Uploaded Python 3

File details

Details for the file locke-0.9.0.tar.gz.

File metadata

  • Download URL: locke-0.9.0.tar.gz
  • Upload date:
  • Size: 94.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for locke-0.9.0.tar.gz
Algorithm Hash digest
SHA256 0699c013320a4cf7b042935e1e5a9b792ff9881745516706e472cbeae2da61ed
MD5 004a37722c035a01b98b050f878e415b
BLAKE2b-256 da9c33da285a6d7f79425d484025b6fe59fed87c7e77735f9279adac903df816

See more details on using hashes here.

File details

Details for the file locke-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: locke-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 61.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for locke-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd8b0956d133b2126e946656d74dba289ab5683bce3a3b32f71f564e47a00314
MD5 a7657c077d6c8901799d8ff40895f9b6
BLAKE2b-256 c63c6b1edfa6309783af95eb35b3dffa4e6c8927651758e4c02ed063df3c09f3

See more details on using hashes here.

Release history Release notifications | RSS feed

0.11.0

2 files

0.10.0

2 files

0.9.1

2 files

This release

0.9.0 This release

2 files

0.8.0

2 files

0.7.0

2 files

0.6.1

2 files

0.5.2

2 files

0.5.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page