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 ENV as an os environment variable like this:

export ENV=<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.1.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.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: envit-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-76060800daily20240311-generic

File hashes

Hashes for envit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a14966dffbedcd5d9a318e9f2c3f68a0c5ae6ff43c43ecf234a49890461153a3
MD5 17620dba9afaecf32cdd2cbe2722f471
BLAKE2b-256 32ac68b772ffeabb6aa938b395b06a5b63d94785ddefbd32a69b4a3ce76c3722

See more details on using hashes here.

File details

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

File metadata

  • Download URL: envit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-76060800daily20240311-generic

File hashes

Hashes for envit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9b79c8da937cd9d35e070781a8f125ed120a8db2b5a845c5fdb5fae681676cd
MD5 9265c52a9b5a14fce3dbe63ae0845230
BLAKE2b-256 a68337ab4bfffe00163ded74620a99cb79bfdb63cdb7f6599de0311d9d0c0ba5

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