Skip to main content

A Django app for managing secrets.

Project description

# django-encrypted-secrets

`django-encrypted-secrets` brings Rails-style [encrypted credentials](https://edgeguides.rubyonrails.org/security.html#custom-credentials) to the [Django web framework](https://www.djangoproject.com/).

## Installation

To install `django-encrypted-secrets`, first pip install the module:

$ pip install django-encrypted-secrets


Add `encrypted_secrets` to INSTALLED_APPS in your django settings file:

INSTALLED_APPS = [
...
'encrypted_secrets'
]

Finally, you must call `load_secrets()` from within your `manage.py` and `wsgi.py` files:


```
#!/usr/bin/env python
import os
import sys
from encrypted_secrets import load_secrets

if __name__ == "__main__":
load_secrets()
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yourapp.settings")
# ...
```

## Usage

Django Secrets works by using a key (stored locally in `master.key` file or read from the environment variable `DJANGO_MASTER_KEY`) and reading/writing secrets to the encrypted file `secrets.yml.enc`.

./manage.py init_secrets

You can edit the secrets by running:

./manage.py edit_secrets

When you save the file in your editor, its contents are encrypted and used to overwrite the `secrets.yml.enc` file.

Finally, to read secrets within your codebase, use the `get_secret` utility:

```
from encrypted_secrets import get_secret

# ...

secret_api_key = get_secret("secret_api_key")

````

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-encrypted-secrets-0.8.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file django-encrypted-secrets-0.8.tar.gz.

File metadata

  • Download URL: django-encrypted-secrets-0.8.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for django-encrypted-secrets-0.8.tar.gz
Algorithm Hash digest
SHA256 501689a83ed5ce329ef228478e0b6786bb85ff9734f1e2ce7638dacff84b6c08
MD5 5c5bd9ab4302e214b95f5f74f3f5451f
BLAKE2b-256 55072d1b5066c264465af98f8759bc77ff6c873d31f42eb8c7dc951c0dce299f

See more details on using hashes here.

Supported by

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