Drop-in dotenv replacement with Windows Hello encryption.
Project description
dotenv-webauthn-crypt
Transparent, WebAuthn-backed encryption for your .env files.
dotenv-webauthn-crypt is a drop-in replacement for python-dotenv that keeps your secrets encrypted at rest and gates access behind WebAuthn (Biometrics/PIN/Phone). Your Master Key never exists in plaintext on disk.
Features
- Seamless Integration: Use
load_dotenv()just like you always have. - Multiple Authentication Devices: Windows Hello (fingerprint/PIN), smartphone (QR code), or USB security key.
- Hardware Security: Private keys stay in the TPM or on your authenticator device.
- Strong Cryptography: AES-256-GCM encryption, HKDF-SHA256 key derivation.
- Vault Isolation: Each
.envfile has its own unique derived vault key. - Platform Diagnostics: Pre-flight checks for TPM, Bluetooth, and network availability.
Installation
Prerequisites
- Windows 10/11 with Windows Hello enabled (for local authentication).
- Bluetooth + Network (for phone/QR authentication).
- Visual Studio 2022 Build Tools (only if building from source).
pip install dotenv-webauthn-crypt
Usage
1. Check available devices
Running init without --device shows a diagnostic report and available options.
--user defaults to your Windows username if not specified:
dotenv-webauthn-crypt-cli init
Output:
--- Platform Authentication Status ---
WebAuthn API version: 9
Platform authenticator: available
Bluetooth: available
Network: available
Choose an authentication device with --device:
--device local Windows Hello (fingerprint/PIN)
Credential stored in the local TPM.
Fast, no extra hardware needed.
--device phone Smartphone via QR code (hybrid)
Credential stored on your phone.
Requires Bluetooth + network.
--device usb USB security key (FIDO2)
Credential stored on the key.
Requires a compatible USB key.
2. Initialize with your chosen device
--user defaults to your Windows username (%USERNAME%) if omitted:
# Windows Hello (fingerprint/PIN) — uses Windows username
dotenv-webauthn-crypt-cli init --device local
# Smartphone via QR code — custom user name
dotenv-webauthn-crypt-cli init --device phone --user MyUser
# USB security key
dotenv-webauthn-crypt-cli init --device usb
3. Encrypt an existing .env file
If no file is specified, defaults to .env in the current directory:
dotenv-webauthn-crypt-cli encrypt
The encrypted file includes a recovery header with credential metadata:
# --- dotenv-webauthn-crypt recovery info ---
# CREDENTIAL_ID="hnemG/M2FN..."
# RP_ID="credentials.dotenv-webauthn.com"
# USER_NAME="MyUser"
# DEVICE="local"
# TRANSPORT="internal"
# AAGUID="adce0002-35bc-c60a-648b-0b25f1f05503"
# CREATED_AT="2026-04-02T10:30:00Z"
# ENCRYPTED_AT="2026-04-02T10:31:00Z"
# VAULT_PATH="C:\Projects\myapp\.env"
# --- end recovery info ---
MY_SECRET=ENC:AQ...
4. Inspect your credential
dotenv-webauthn-crypt-cli info
Output:
--- Credential Information ---
Credential ID : hnemG/M2FNfuigrJ3BUP5kj9DYudDEL1...
Domain (RP_ID): credentials.dotenv-webauthn.com
User name : MyUser
Device : local (Windows Hello (fingerprint/PIN))
Transport : internal
AAGUID : adce0002-35bc-c60a-648b-0b25f1f05503
Authenticator : Windows Hello
Created at : 2026-04-02T10:30:00Z
The info command also queries the AAGUID database to display the authenticator name (e.g., "Samsung Galaxy", "YubiKey 5").
5. Load in your Python code
from dotenv_webauthn_crypt import load_dotenv
# Triggers an authentication prompt if encrypted values are detected
load_dotenv() # comment lines in the .env file are ignored
import os
print(os.environ.get("MY_SECRET_KEY"))
Authentication Devices
| Device | --device |
Where key lives | Requirements |
|---|---|---|---|
| Windows Hello | local |
Local TPM | Windows Hello PIN or biometrics |
| Smartphone | phone |
Phone | Bluetooth + network connectivity |
| USB key | usb |
Security key | FIDO2-compatible USB key |
The init command runs pre-flight diagnostics and reports which devices are available. If a device is unavailable, it explains why (e.g., Bluetooth off, no network, no TPM).
Architecture
- Registration:
initcreates a non-resident public/private key pair on the chosen authenticator. TheCredentialIDand metadata (AAGUID, transport, device, user, timestamp) are saved locally. - Encryption: A
VaultKeyis derived using HKDF from an authenticator-backed signature and the file's canonical path. A recovery header with credential metadata is prepended to the encrypted file. - Loading:
load_dotenvskips comment lines (#), detectsENC:prefixes, triggers authentication to get a fresh signature, re-derives theVaultKey, and decrypts the values intoos.environ. - Info:
inforeads the credential metadata and queries the AAGUID database to identify the authenticator model.
TODO / Roadmap
- Windows Hello (TPM) authentication
- Smartphone (hybrid/QR) authentication
- USB security key authentication
- Platform diagnostics (TPM, Bluetooth, network)
- Credential metadata and recovery headers
- AAGUID-based authenticator identification
- Linux Support: Backend using TPM2-TSS or libfido2.
- macOS Support: Backend using Secure Enclave / Touch ID.
- Credential Rotation:
rekeycommand to migrate between hardware credentials.
Browser-based WebAuthn Test
tests/test_browser_webauthn.py is a standalone prototype that uses a local browser as the WebAuthn client instead of the native C++ module. It starts an HTTP server on localhost:8580, opens the default browser, and delegates navigator.credentials.create() / .get() to the browser's built-in WebAuthn support.
Prerequisites: Windows Hello must be provisioned (NGC active). See TODO_BUGS.md for NGC troubleshooting.
# Create a platform credential (triggers Windows Hello in the browser)
python tests/test_browser_webauthn.py create
# Sign with the saved credential
python tests/test_browser_webauthn.py sign
License
Distributed under the MIT License. See LICENSE for more information.
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 Distributions
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 dotenv_webauthn_crypt-0.3.0a7.tar.gz.
File metadata
- Download URL: dotenv_webauthn_crypt-0.3.0a7.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92a238979d20d9b0550585dc89074d9b352778ad9fed5b0d1ce94940a46ba1b2
|
|
| MD5 |
0da9a14aa02d921ecc7138a7eaf42b6c
|
|
| BLAKE2b-256 |
e9449730f318810be6f64d5dbb9b303661e0aca94e3a47d730b62f2beaf90788
|
Provenance
The following attestation bundles were made for dotenv_webauthn_crypt-0.3.0a7.tar.gz:
Publisher:
build_wheels.yml on joseluu/dotenv-webauthn-crypt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dotenv_webauthn_crypt-0.3.0a7.tar.gz -
Subject digest:
92a238979d20d9b0550585dc89074d9b352778ad9fed5b0d1ce94940a46ba1b2 - Sigstore transparency entry: 1209840038
- Sigstore integration time:
-
Permalink:
joseluu/dotenv-webauthn-crypt@efa29e2525466d69f0d54da5585a595bc84ef8f5 -
Branch / Tag:
refs/tags/v0.3.0a7 - Owner: https://github.com/joseluu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@efa29e2525466d69f0d54da5585a595bc84ef8f5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dotenv_webauthn_crypt-0.3.0a7-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: dotenv_webauthn_crypt-0.3.0a7-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 89.7 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d66b2a1b2a9a4ba5cf13c95f752b1376aedfa9196c805aaff7e390a536ae628d
|
|
| MD5 |
8e667b3ce3abfce62995a1caae5c235b
|
|
| BLAKE2b-256 |
b9f45a5c819bde53b8df05170e86a91d315e6b5ef955e8d5ae03674b1b40af2a
|
Provenance
The following attestation bundles were made for dotenv_webauthn_crypt-0.3.0a7-cp312-cp312-win_amd64.whl:
Publisher:
build_wheels.yml on joseluu/dotenv-webauthn-crypt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dotenv_webauthn_crypt-0.3.0a7-cp312-cp312-win_amd64.whl -
Subject digest:
d66b2a1b2a9a4ba5cf13c95f752b1376aedfa9196c805aaff7e390a536ae628d - Sigstore transparency entry: 1209840186
- Sigstore integration time:
-
Permalink:
joseluu/dotenv-webauthn-crypt@efa29e2525466d69f0d54da5585a595bc84ef8f5 -
Branch / Tag:
refs/tags/v0.3.0a7 - Owner: https://github.com/joseluu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@efa29e2525466d69f0d54da5585a595bc84ef8f5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dotenv_webauthn_crypt-0.3.0a7-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: dotenv_webauthn_crypt-0.3.0a7-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 89.3 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58db62e97fa6404d91ccdd6c917fc8a70ec64f6fcbf71568937b6d0afa3ac982
|
|
| MD5 |
a8e36c923fe8e1ae2cb9e9ec6a4d4da9
|
|
| BLAKE2b-256 |
7a36f4946714c259c07faf23a1be777ef3d52baf25ea37538692341993bea14f
|
Provenance
The following attestation bundles were made for dotenv_webauthn_crypt-0.3.0a7-cp311-cp311-win_amd64.whl:
Publisher:
build_wheels.yml on joseluu/dotenv-webauthn-crypt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dotenv_webauthn_crypt-0.3.0a7-cp311-cp311-win_amd64.whl -
Subject digest:
58db62e97fa6404d91ccdd6c917fc8a70ec64f6fcbf71568937b6d0afa3ac982 - Sigstore transparency entry: 1209840101
- Sigstore integration time:
-
Permalink:
joseluu/dotenv-webauthn-crypt@efa29e2525466d69f0d54da5585a595bc84ef8f5 -
Branch / Tag:
refs/tags/v0.3.0a7 - Owner: https://github.com/joseluu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@efa29e2525466d69f0d54da5585a595bc84ef8f5 -
Trigger Event:
release
-
Statement type: