Skip to main content

Django package for managing a single root encryption key and decrypting embedded secrets.

Project description

django-root-secret

Tests

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. 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=...

Encrypt a plaintext secret using that file:

python manage.py encrypt_secret --env development --value "my-db-password"

Use the encrypted output in code and decrypt it with ROOT_ENCRYPTION_KEY from the runtime environment:

from django_root_secret import get_secret

DATABASE_PASSWORD = get_secret("gAAAAAB...")

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

django_root_secret-0.1.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

django_root_secret-0.1.2-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file django_root_secret-0.1.2.tar.gz.

File metadata

  • Download URL: django_root_secret-0.1.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_root_secret-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4ecaecbf1216cc6db4c2c16c211682b2e3bac9dcd152846a7f27c2093431a8c5
MD5 32a8a628f08163a4bea2202da9f79f14
BLAKE2b-256 f683c7b4afdb89a8ab3a149f7c7d3a7065faa07fc4dbcb6813cb6cd64e6ba1c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_root_secret-0.1.2.tar.gz:

Publisher: publish.yml on efe/django-root-secret

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_root_secret-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_root_secret-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cec1a057c5fa45f24939682b4c5843f95e7214b7b1ee7da975ce9b8966964be3
MD5 8aae5a9b0689325c7a0293820de20db6
BLAKE2b-256 11eb1c9905a58f0ed10ffa9c0db49a429a62ef0cd56f8a42a6ff9f7f96c1808c

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_root_secret-0.1.2-py3-none-any.whl:

Publisher: publish.yml on efe/django-root-secret

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page