DJANGO OUTBOX ENCRYPTION
Project description
DJANGO OUTBOX ENCRYPTION
Sometimes, when you ready to publish your project to server.
There is a slight change between the application settings on the local and the server. Such as database name, password, etc. The second thing, is you need to encrypt information like password or other. The last one, you need to automatically select setting local when you work on local computer, and auto select server when application running on server.
You are on the right path...
Install package to your environment
> pip install outbox-encryption
How to use
Encrypt to environment
This code for create ".env.client" or ".env.server" file
> python manage.py shell
> from encryption import OutboxEncryption
> lib = OutboxEncryption()
> mplaint_text = {
'DB_PASSWORD': '',
'SECRET_KEY': 'xxg_7me8rl2m#a_h2oresgt2#ni=3_4*!ai*=rtsq)yi!g7_5-51xx'
}
> lib.encrypt_environ('.env.local', mplaint_text)
# file .env.local is created (maybe file is hidden, CTRL+H to show it)
# Open file .env.local
You have to write other setting that no encrypt apply, such as:
DEBUG=True
UNDER_CONSTRUCTION=False
DB_ENGINE=django.db.backends.mysql
DB_NAME=db_name
DB_USER=root
DB_HOST=127.0.0.1
DB_PORT=3306
Note:
File .env.local must be :
.env.local or
.env.server (nothing else)
Decrypt from environment
Run inside settings.py (django project settings)
> from encryption import OutboxEncryption
> lib = OutboxEncryption()
Setting unique variable that only exists in local environment, and not exist in server
We choose env_outbox_encrypt
> lib.set_keyword_local('env_outbox_encrypt')
List of key variable that must be encrypt or decrypt before set or get data
> mplaint_key = ['DB_PASSWORD', 'SECRET_KEY']
Variable that must be cast as list from environmnet to settings.py
> mplaint_list = ['ALLOWED_HOSTS']
Variable that must be cast as tuple from environment to settings.py
> mplaint_tuple = ['SECURE_PROXY_SSL_HEADER']
Get encryption data
> dict1 = lib.decrypt_environ(mplaint_key, mplaint_list, mplaint_tuple)
Setting variable :
> DEBUG = dict1['DEBUG']
> UNDER_CONSTRUCTION = dict1['UNDER_CONSTRUCTION']
> DEBUG = dict1['DEBUG']
> SECRET_KEY = dict1['SECRET_KEY']
> ALLOWED_HOSTS = dict1['ALLOWED_HOSTS']
> DATABASES = {
'default': {
'ENGINE' : dict1['DB_ENGINE'],
'NAME' : dict1['DB_NAME'],
'USER' : dict1['DB_USER'],
'PASSWORD' : dict1['DB_PASSWORD'],
'HOST' : dict1['DB_HOST'],
'PORT' : dict1['DB_PORT'],
}
> SECURE_PROXY_SSL_HEADER = dict1['SECURE_PROXY_SSL_HEADER']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file outbox-encryption-1.0.7.tar.gz
.
File metadata
- Download URL: outbox-encryption-1.0.7.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84407f2f75351849d629b707ad06b9185f4db2cb05de191a506b5ce7be633a73 |
|
MD5 | 23f18e6ea302d0cc4b4263848fce227d |
|
BLAKE2b-256 | 42c9f663e5a28fe8e83695f43beaaebe369e7e37b7fe61abe5961858f1979fca |
Provenance
File details
Details for the file outbox_encryption-1.0.7-py3-none-any.whl
.
File metadata
- Download URL: outbox_encryption-1.0.7-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6b251be29164966b2b44573771c9b50325324637c32c2503a7ba011b5709fe2 |
|
MD5 | e4abc19eb1c3b6063cddcfc5bd256ae2 |
|
BLAKE2b-256 | 976d1dcac3cf5e52bee3ff2eb3ed2ea07b86ab123689189d4f7cb667555972c9 |