outbox-encryption


Nameoutbox-encryption JSON
Version 1.1.5 PyPI version JSON
download
home_pagehttps://github.com/PROJECT-OUTBOX/django_lib_outbox_encryption.git
SummaryDJANGO OUTBOX ENCRYPTION
upload_time2024-03-29 00:19:15
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords encrypt decrypt environment django settings
VCS
bugtrack_url
requirements asgiref cffi cryptography Django pycparser python-decouple sqlparse
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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 it works
    On developing time, library will scan your environment variable
    to get file name specific for you computer, for example : .env-outbox-python
    this file must exists on your source code to make application continue.

    On deploy time, for example your local computer, library again will scan your
    environment variable and get file name base on computer where it running

    if file found, application continue, else stop application

    if you ready to deploy to server, just rename file .env-outbox-python to name 
    which is must be found on server

## How to use 

### Create Encrypt 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.enc_environ(mplaint_text)
    # new file is created (maybe file is hidden, CTRL+H to show it)

    # Open new file that recently created
        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 name auto create base on environment variable on running computer.
    If run on server just rename this file, and write setting needed to run website on server

### Decrypt environment file
    > python manage.py shell

    > from encryption import OutboxEncryption
    > lib = OutboxEncryption()

    > mplaint_key = {
        'DB_PASSWORD',
        'SECRET_KEY'
        }
    > mplaint_list = {
        'ALLOWED_HOSTS',
        'CSRF_TRUSTED_ORIGINS'
        }
    > key = lib.dec_environ(mplaint_key, mplaint_list)
    > print (key)

### Change your settings.py file
    # Write inside settings.py (django project settings): 

    > from encryption import OutboxEncryption
    > lib = OutboxEncryption()

    # 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', 'CSRF_TRUSTED_ORIGINS']

    Variable that must be cast as tuple from environment to settings.py
    > mplaint_tuple = ['SECURE_PROXY_SSL_HEADER']

    Get encryption data
    > key = lib.decrypt_environ(mplaint_key, mplaint_list, mplaint_tuple)

    Setting variable :
    > DEBUG = key['DEBUG']
    > UNDER_CONSTRUCTION = key['UNDER_CONSTRUCTION']
    > DEBUG = key['DEBUG']
    > SECRET_KEY = key['SECRET_KEY']
    > ALLOWED_HOSTS = key['ALLOWED_HOSTS']

    > tmp_engine = key['DB_ENGINE']
    > if 'sqlite3' in tmp_engine:
        DATABASES = {
            'default': {
                'ENGINE': tmp_engine,                
                'NAME': key['DB_NAME'],   # complete path 
            }
        }
    > else: # default 
    >   DATABASES = {
            'default': {
                'ENGINE'    : key['DB_ENGINE'],
                'NAME'      : key['DB_NAME'],
                'USER'      : key['DB_USER'],
                'PASSWORD'  : key['DB_PASSWORD'],
                'HOST'      : key['DB_HOST'],
                'PORT'      : key['DB_PORT'],
            }

    > SECURE_PROXY_SSL_HEADER = key['SECURE_PROXY_SSL_HEADER']

    # Optional:
    > tmp = key.get('CSRF_TRUSTED_ORIGINS') 
    > if tmp:
    >   CSRF_TRUSTED_ORIGINS=key['CSRF_TRUSTED_ORIGINS']

    # # use default value if setting not exists
    > tmp = key.get('STATIC_ROOT')  # True if exists, None if not exists
    > STATIC_ROOT = key['STATIC_ROOT'] if tmp else os.path.join(BASE_DIR, 'staticfiles')

    > tmp = key.get('MEDIA_ROOT')
    > MEDIA_ROOT = key['MEDIA_ROOT'] if tmp else os.path.join(BASE_DIR, 'media')


    
    

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PROJECT-OUTBOX/django_lib_outbox_encryption.git",
    "name": "outbox-encryption",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "encrypt, decrypt, environment, django, settings",
    "author": null,
    "author_email": "suratiwan03@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/41/98/1f446a420caa0cbaaa62e65781eb5c03b84a798f444e599d84c53b418fd6/outbox-encryption-1.1.5.tar.gz",
    "platform": null,
    "description": "# DJANGO OUTBOX ENCRYPTION\n\nSometimes, when you ready to publish your project to server. \n\nThere is a slight change between the application settings on the local and the server.\nSuch as database name, password, etc.\nThe second thing, is you need to encrypt information like password or other.\nThe last one, you need to automatically select setting local when you work on local computer, and auto select server when application running on server.\n\nYou are on the right path...\n\n\n## Install package to your environment\n    > pip install outbox-encryption\n\n## How it works\n    On developing time, library will scan your environment variable\n    to get file name specific for you computer, for example : .env-outbox-python\n    this file must exists on your source code to make application continue.\n\n    On deploy time, for example your local computer, library again will scan your\n    environment variable and get file name base on computer where it running\n\n    if file found, application continue, else stop application\n\n    if you ready to deploy to server, just rename file .env-outbox-python to name \n    which is must be found on server\n\n## How to use \n\n### Create Encrypt File    \n    > python manage.py shell\n\n    > from encryption import OutboxEncryption\n    > lib = OutboxEncryption()\n    > mplaint_text = {\n            'DB_PASSWORD': '',\n            'SECRET_KEY': 'xxg_7me8rl2m#a_h2oresgt2#ni=3_4*!ai*=rtsq)yi!g7_5-51xx'\n        }\n    > lib.enc_environ(mplaint_text)\n    # new file is created (maybe file is hidden, CTRL+H to show it)\n\n    # Open new file that recently created\n        You have to write other setting that no encrypt apply, such as:\n\n        DEBUG=True\n        UNDER_CONSTRUCTION=False\n        DB_ENGINE=django.db.backends.mysql\n        DB_NAME=db_name\n        DB_USER=root\n        DB_HOST=127.0.0.1\n        DB_PORT=3306\n\n#### Note:\n    File name auto create base on environment variable on running computer.\n    If run on server just rename this file, and write setting needed to run website on server\n\n### Decrypt environment file\n    > python manage.py shell\n\n    > from encryption import OutboxEncryption\n    > lib = OutboxEncryption()\n\n    > mplaint_key = {\n        'DB_PASSWORD',\n        'SECRET_KEY'\n        }\n    > mplaint_list = {\n        'ALLOWED_HOSTS',\n        'CSRF_TRUSTED_ORIGINS'\n        }\n    > key = lib.dec_environ(mplaint_key, mplaint_list)\n    > print (key)\n\n### Change your settings.py file\n    # Write inside settings.py (django project settings): \n\n    > from encryption import OutboxEncryption\n    > lib = OutboxEncryption()\n\n    # List of key variable that must be encrypt or decrypt before set or get data\n    > mplaint_key = ['DB_PASSWORD', 'SECRET_KEY']\n\n    Variable that must be cast as list from environmnet to settings.py\n    > mplaint_list = ['ALLOWED_HOSTS', 'CSRF_TRUSTED_ORIGINS']\n\n    Variable that must be cast as tuple from environment to settings.py\n    > mplaint_tuple = ['SECURE_PROXY_SSL_HEADER']\n\n    Get encryption data\n    > key = lib.decrypt_environ(mplaint_key, mplaint_list, mplaint_tuple)\n\n    Setting variable :\n    > DEBUG = key['DEBUG']\n    > UNDER_CONSTRUCTION = key['UNDER_CONSTRUCTION']\n    > DEBUG = key['DEBUG']\n    > SECRET_KEY = key['SECRET_KEY']\n    > ALLOWED_HOSTS = key['ALLOWED_HOSTS']\n\n    > tmp_engine = key['DB_ENGINE']\n    > if 'sqlite3' in tmp_engine:\n        DATABASES = {\n            'default': {\n                'ENGINE': tmp_engine,                \n                'NAME': key['DB_NAME'],   # complete path \n            }\n        }\n    > else: # default \n    >   DATABASES = {\n            'default': {\n                'ENGINE'    : key['DB_ENGINE'],\n                'NAME'      : key['DB_NAME'],\n                'USER'      : key['DB_USER'],\n                'PASSWORD'  : key['DB_PASSWORD'],\n                'HOST'      : key['DB_HOST'],\n                'PORT'      : key['DB_PORT'],\n            }\n\n    > SECURE_PROXY_SSL_HEADER = key['SECURE_PROXY_SSL_HEADER']\n\n    # Optional:\n    > tmp = key.get('CSRF_TRUSTED_ORIGINS') \n    > if tmp:\n    >   CSRF_TRUSTED_ORIGINS=key['CSRF_TRUSTED_ORIGINS']\n\n    # # use default value if setting not exists\n    > tmp = key.get('STATIC_ROOT')  # True if exists, None if not exists\n    > STATIC_ROOT = key['STATIC_ROOT'] if tmp else os.path.join(BASE_DIR, 'staticfiles')\n\n    > tmp = key.get('MEDIA_ROOT')\n    > MEDIA_ROOT = key['MEDIA_ROOT'] if tmp else os.path.join(BASE_DIR, 'media')\n\n\n    \n    \n",
    "bugtrack_url": null,
    "license": null,
    "summary": "DJANGO OUTBOX ENCRYPTION",
    "version": "1.1.5",
    "project_urls": {
        "Homepage": "https://github.com/PROJECT-OUTBOX/django_lib_outbox_encryption.git"
    },
    "split_keywords": [
        "encrypt",
        " decrypt",
        " environment",
        " django",
        " settings"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "58e1d79ac7e72b3c68f0951d7dff5ab5c3c15621def2b0445414f0de2b295f03",
                "md5": "4d2f0f8358912bb85f1dec97da414a60",
                "sha256": "0f4e1384f9a11666aef8aec9dd99e94e40af12642d5d433e3a473d07514583a5"
            },
            "downloads": -1,
            "filename": "outbox_encryption-1.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4d2f0f8358912bb85f1dec97da414a60",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11816,
            "upload_time": "2024-03-29T00:19:13",
            "upload_time_iso_8601": "2024-03-29T00:19:13.476085Z",
            "url": "https://files.pythonhosted.org/packages/58/e1/d79ac7e72b3c68f0951d7dff5ab5c3c15621def2b0445414f0de2b295f03/outbox_encryption-1.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "41981f446a420caa0cbaaa62e65781eb5c03b84a798f444e599d84c53b418fd6",
                "md5": "349f8b8b5b361fdd6f0d8f17f64f3478",
                "sha256": "91e2f1d58e1e5ca5d0e633df587905000620776fa3f0d585873090df7fd7ae89"
            },
            "downloads": -1,
            "filename": "outbox-encryption-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "349f8b8b5b361fdd6f0d8f17f64f3478",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13775,
            "upload_time": "2024-03-29T00:19:15",
            "upload_time_iso_8601": "2024-03-29T00:19:15.237920Z",
            "url": "https://files.pythonhosted.org/packages/41/98/1f446a420caa0cbaaa62e65781eb5c03b84a798f444e599d84c53b418fd6/outbox-encryption-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-29 00:19:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PROJECT-OUTBOX",
    "github_project": "django_lib_outbox_encryption",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "asgiref",
            "specs": [
                [
                    "==",
                    "3.5.2"
                ]
            ]
        },
        {
            "name": "cffi",
            "specs": [
                [
                    "==",
                    "1.15.1"
                ]
            ]
        },
        {
            "name": "cryptography",
            "specs": [
                [
                    "==",
                    "38.0.1"
                ]
            ]
        },
        {
            "name": "Django",
            "specs": [
                [
                    "==",
                    "4.1.1"
                ]
            ]
        },
        {
            "name": "pycparser",
            "specs": [
                [
                    "==",
                    "2.21"
                ]
            ]
        },
        {
            "name": "python-decouple",
            "specs": [
                [
                    "==",
                    "3.6"
                ]
            ]
        },
        {
            "name": "sqlparse",
            "specs": [
                [
                    "==",
                    "0.4.3"
                ]
            ]
        }
    ],
    "lcname": "outbox-encryption"
}
        
Elapsed time: 0.26365s