A tiny op-first secret resolver with environment fallback.
Project description
secretpath
secretpath resolves application secrets from a short, explicit provider path:
- 1Password CLI references through
op read - Environment variables
It is designed for CLIs and local automation that should prefer 1Password when available, fall back to environment variables when appropriate, and report where the secret came from without logging the secret itself.
secretpath never writes resolved secret values to disk. Its cache is
process-local memory only.
Install
pip install secretpath
For local development:
uv sync
uv run pytest
uv run ruff check src tests
Quick Start
from secretpath import resolve_secret
result = resolve_secret(
"Canvas API key",
provider="auto",
op_reference="op://Vault/Canvas/credential",
env_var="CANVAS_API_KEY",
)
api_key = result.value
print(f"Using API key from {result.source}")
Use environment variables to avoid putting op://... references in project
files:
result = resolve_secret(
"ANTHROPIC_API_KEY",
provider_env="MYAPP_SECRET_PROVIDER",
op_reference_env="MYAPP_ANTHROPIC_API_KEY_OP_REFERENCE",
)
For prefix-based project conventions:
from secretpath import resolve_env_secret
result = resolve_env_secret("ANTHROPIC_API_KEY", prefix="PIPYER")
That reads:
PIPYER_SECRET_PROVIDERPIPYER_ANTHROPIC_API_KEY_OP_REFERENCEANTHROPIC_API_KEY
Named Config
Local .secretpath.toml and global ~/.config/secretpath/config.toml files can
store secret lookup metadata. They should contain references and environment
variable names, not resolved secret values.
[defaults]
provider = "auto"
[secrets.canvas]
env_var = "CANVAS_API_KEY"
op_reference = "op://Vault/Canvas/credential"
[secrets.anthropic]
env_var = "ANTHROPIC_API_KEY"
op_reference_env = "MYAPP_ANTHROPIC_API_KEY_OP_REFERENCE"
Then:
from secretpath import resolve_named_secret
result = resolve_named_secret("canvas")
See docs/config.md for precedence and file discovery.
CLI
The CLI checks whether a secret resolves without printing the secret:
secretpath check canvas
sp check canvas
secretpath check canvas --json
secretpath list
secretpath config path
secretpath config init
secretpath config show
secretpath doctor
secretpath doctor --check
sp direnv init openai anthropic
secretpath check ANTHROPIC_API_KEY --prefix PIPYER
secretpath check API_KEY --no-config --env-var API_KEY
python -m secretpath check canvas
sp is a short alias for the secretpath command.
See docs/cli.md.
Behavior
provider="auto"tries1passwordfirst, thenenv.provider="1password"only triesop read.provider="env"only reads the environment variable.env_vardefaults toname.- environment-sourced results report
env:<env_var>, such asenv:CANVAS_API_KEY. required=Falsereturns aSecretMisswith non-secret attempt metadata.- resolved values are cached in process memory by default.
clear_cache()clears the process-local cache.clear_cache(name)clears entries for one logical secret name.
Error messages name providers tried, but intentionally avoid including
op://... references, environment variable names, raw op stderr, or secret
values.
Documentation
Why No Durable Secret Cache?
secretpath treats 1Password or the environment as the durable authority. A
disk cache would create another secret store with weaker rotation and audit
semantics. The built-in cache is intentionally limited to the current Python
process.
Project details
Release history Release notifications | RSS feed
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 secretpath-0.2.0.tar.gz.
File metadata
- Download URL: secretpath-0.2.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1f66933ac3849668b303913224831daac9cffe913525a197bb26dde1d61fc3e
|
|
| MD5 |
5b1cfb30712e505c8d3382191e28cf1e
|
|
| BLAKE2b-256 |
1ba9b9fe863f4ad62f27de5525fa0176fc5c45bc91d465cc943b9ebb66b90196
|
File details
Details for the file secretpath-0.2.0-py3-none-any.whl.
File metadata
- Download URL: secretpath-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8c3c06777363dd4625d5c2974abba1bed8d2b1b043d32b93271a191f5acd579
|
|
| MD5 |
6fca04dd027c9f00eae889f8d6edb4a1
|
|
| BLAKE2b-256 |
95db62d777a73deb04a4ad52399fe7d2f18e7fbb86372df7033e71bdc9ca03ff
|