Skip to main content

Managing multiple environments credentials easily

Project description

MIT License

Env It!

Envit is a Python library and command-line interface (CLI) tool for securely encrypting and decrypting environment variable files.

Features

  • Encrypt environment variable files before storing them in a Git repository
  • Decrypt encrypted environment variable files for local usage
  • Generate Secret keys for encryption and decryption

Installation

pip install envit

Usage

Create a envs directory in root of you project. put your environment .env files there. here is directory structure:

sample-project
├── envs
│   ├── development.env
│   ├── staging.env
│   └── production.env
├── main.py
├── README.md
└── requirements.txt

Note: Make sure your .env files included in .gitignore

envs/*.env

for example your production.env looks like this:

# DATABASE
DB_HOST=database
DB_NAME=mydb
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=strongpassword
.
.
.

Generate an encryption key

ev keygen

This will output a randomly generated encryption key.

Encrypt Environment Variables

ev encrypt -e <environment> -k <encryption_key>

This will create a file named <envrionment>.env.enc in envs directory

Decrypt Environment Variables

ev decrypt -e <environment> -k <encryption_key>

This will create or overwrite existing <environment>.env file in envs directory

Finally, your project structure looks like this:

sample-project
├── envs
│   ├── development.env
│   ├── development.env.enc
│   ├── staging.env
│   ├── staging.env.enc
│   └── production.env
│   └── production.env.enc
├── main.py
├── README.md
└── requirements.txt

After all you can decrypt your credentials in desired environment with having corresponding secret key.

Coding

Export ENVIRONMENT as an os environment variable like this:

export ENVIRONMENT=<environment>

Now you can easily get your environment variables. we used python-decouple inside.

from envit.core import config
from decouple import CSV

ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=CSV())
DB_HOST = config('DB_HOST', default='localhost')
DB_PORT = config('DB_PORT', cast=int, default=5432)
...

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

envit-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

envit-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file envit-0.1.0.tar.gz.

File metadata

  • Download URL: envit-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/5.15.0-91-generic

File hashes

Hashes for envit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7f3256dc742934bf7a84d206d0cec9bb1492ebd80fb79fa0c6f8d7dd812cd66a
MD5 cbfab09b56af05f87a72313de6ed6ec8
BLAKE2b-256 8c69526480fcec6807ba74902abe99f52724b6e34460d6806030a4f742523928

See more details on using hashes here.

File details

Details for the file envit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: envit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/5.15.0-91-generic

File hashes

Hashes for envit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09dc8a477416549694868d3fbe5bddb17275367228f1f5b140df7f753d2b5adf
MD5 707a94daec2eb3667facb42808dbbac6
BLAKE2b-256 dedbd89e08b4cd732e0481fcf363983b60d8e256da6e1cf5b67f89013439f52b

See more details on using hashes here.

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