Django package for managing a single root encryption key and decrypting embedded secrets.
Project description
django-root-secret
django-root-secret is a Django package for managing one root encryption key per environment and decrypting encrypted literals at runtime.
django-root-secret reduces the number of plaintext secrets you need to manage and tries to minimize the number of environment variables your project depends on. Large .env files are a common source of configuration errors because variables can be missing, misnamed, outdated, or inconsistent across environments. This package keeps the env file minimal by storing only ROOT_ENCRYPTION_KEY there and encrypting the rest.
Installation
Install the package:
pip install django-root-secret
Add the app to INSTALLED_APPS:
INSTALLED_APPS = [
...,
"django_root_secret",
]
Commands
Generate a root key file:
python manage.py generate_root_encryption_key --env development
This creates development.env in the current working directory with only:
# This file must only contain ROOT_ENCRYPTION_KEY.
# Encrypt every other secret with this key and keep the file private.
ROOT_ENCRYPTION_KEY=...
If development.env is not already ignored by Git, the command also adds it to .gitignore.
Encrypt a plaintext secret using that file and bring up a prompt to paste the secret:
python manage.py encrypt_secret --env development
# Value to encrypt: [hidden input]
At runtime, make ROOT_ENCRYPTION_KEY available through your environment or deployment secret manager:
export ROOT_ENCRYPTION_KEY="..."
Then use the encrypted output in code:
from django_root_secret import get_secret
DATABASE_PASSWORD = get_secret("gAAAAAB...")
Note
This package started as an internal tool at Hipo, and it brings back memories of a team I still appreciate deeply. 🦛
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 django_root_secret-0.2.0.tar.gz.
File metadata
- Download URL: django_root_secret-0.2.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27b015117aec1e492e0a029af63705c4cc805912fd33c8b28b4c69a08c9f740d
|
|
| MD5 |
26fc016d9b7ec9b76ef52c707b9556af
|
|
| BLAKE2b-256 |
fe99135bca49027c311c57b027a31503c3cf5cca06ed01e983bd8a2092fa1fe2
|
Provenance
The following attestation bundles were made for django_root_secret-0.2.0.tar.gz:
Publisher:
publish.yml on efe/django-root-secret
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_root_secret-0.2.0.tar.gz -
Subject digest:
27b015117aec1e492e0a029af63705c4cc805912fd33c8b28b4c69a08c9f740d - Sigstore transparency entry: 1154310673
- Sigstore integration time:
-
Permalink:
efe/django-root-secret@ba344a6544edabd471820e07eb6206d8eecfcff5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/efe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ba344a6544edabd471820e07eb6206d8eecfcff5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_root_secret-0.2.0-py3-none-any.whl.
File metadata
- Download URL: django_root_secret-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c29f08dae5aab9e54084ca38a7823153567b066b35627b7fc168f9916c7d9558
|
|
| MD5 |
0a7fcb4fdaf56d99c0febb64dbff417c
|
|
| BLAKE2b-256 |
bf914eb1901ef1ac05711ff756ee9afc2eb6526e36c242ab6667e61ab2440c96
|
Provenance
The following attestation bundles were made for django_root_secret-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on efe/django-root-secret
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_root_secret-0.2.0-py3-none-any.whl -
Subject digest:
c29f08dae5aab9e54084ca38a7823153567b066b35627b7fc168f9916c7d9558 - Sigstore transparency entry: 1154310675
- Sigstore integration time:
-
Permalink:
efe/django-root-secret@ba344a6544edabd471820e07eb6206d8eecfcff5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/efe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ba344a6544edabd471820e07eb6206d8eecfcff5 -
Trigger Event:
push
-
Statement type: