djangosecure
Secure Django settings (Works with
other Python scripts)
This module creates a cryptokey outside the django project directory, encrypts with that cryptokey your django sensible settings and stores the encrypted values.
You can use it at your project settings.py file * Note: Before running the django site with gunicorn or similar for the first time, you must run somme manage command to be prompt for the sensible settings * Developed for Linux/Python2.7, Python3.5
Install
Linux required packages: python-dev (python3.5-dev if python==3.5) libgmp-dev gcc pip install djangosecure
Examples
SECRET_KEY
settings.py
from djangosecure import DjangoSecretKey SECRET_KEY_FILE_PATH = '/some/path/to/store/file.secret' secret_key = DjangoSecretKey(SECRET_KEY_FILE_PATH) SECRET_KEY = secret_key.key
Note: If the secret key file path does not exist it will try to create it. (write permissio required @SECRET_KEY_FILE_PATH origin)
Note: The secret file will be automatically created the first time you call secret_key.key
The cryptographic key is stored by default at ~/.private/django_secure.key you can change this by passing crypto_key_file= to the DjangoSecretKey constructor: secret_key = DjangoSecretKey(SECRET_KEY_FILE_PATH, crypto_key_file='path/to/your/cryptokey') DjangoDatabaseSettings and EncryptedStoredSettings accept crypto_key_file parameter too.
DATABASES
The first time you run python manage.py runserver you will be prompted for your database settings. They will be saved encrypted with the generated cryptokey generated by django-secure module.
You can have as many database configurations, change the parameter to change the configuration and running python manage.py runserver you will be prompted again for the new settings
from djangosecure import DjangoDatabaseSettings
databases = DjangoDatabaseSettings(os.path.join(PROJECT_ROOT, 'databases.cnf'), crypto_key_file='path/to/your/cryptokey)
DATABASES = {
'default': 'default': databases.settings('production'),
}
Other settings
To encrypt any other setting use EncryptedStoredSettings, for example:
from djangosecure import EncryptedStoredSettings
encripted_settings = EncryptedStoredSettings('./hidden/settings/path'))
CELERY_BROKER = 'amqp://{0}:{1}@localhost//'.format(
encripted_settings.get('celery', 'broker_username', config_file="config/file/path/here.cfg"),
encripted_settings.get('celery', 'broker_password')
)
Runing tests
nosetests –with-coverage –cover-html
nosetests –with-coverage –cover-html –cover-inclusive –cover-package=djangosecure
Note: File and path are automatically created at first call
Metadata
Release files for djangosecure 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djangosecure-0.0.11.tar.gz | 8.6 kB | Without provenance | Details for djangosecure-0.0.11.tar.gz |
Release files / djangosecure-0.0.11.tar.gz
| Download URL | djangosecure-0.0.11.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5358b12a3557c5b54cb69a2ae9a3e00d0c80efd9ca5c3edbf90eadc723262045
|
|
BLAKE2b-256 checksum How to use checksums |
5e331acb29891777386ec1582ec1acfaa14b5475e7596ea0259e128ceba7addc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Security for djangosecure 0.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.