Skip to main content

A library to maintain and use encrypted .env files.

Project description

Env Credentials

Manage environment variables use the dotenv pattern with encrypted files.

This project is an attempted port of the credentials pattern found in Ruby on Rails.

Installation

Using pip:

pip install env-credentials[django]

Using poetry:

poetry add env-credentials[django]

Usage

Initializing and editing the encrypted credentials file is only supported with Django at this time. Additional CLI tooling can be built for framework-less projects or projects using other frameworks.

Django

After adding the dependency to your project, add the Django app

INSTALLED_APPS = [
    # ...
    'django_credentials',
    # ...
]

You can then initialize the credentials files with

./manage.py init_credentials

This will create a two new files called master.key and credentials.env.enc in your root folder. If a .gitignore file exists in the same directory, it will also add master.key to it.

Be sure to ignore your master.key file if the gitignore file cannot be automatically updated.

You can then edit the values in the file using

./manage.py edit_credentials

Be sure that your $EDITOR environment variable is set, as that is what the decrypted file will be opened with.

Finally, to load the values into your environment, you should add the following code to your wsgi.py and manage.py files

from env_credentials.credentials import Credentials

Credentials().load()

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

env-credentials-0.1.0.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

env_credentials-0.1.0-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

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