Encrypt credentials/Django settings to store in repositories
Project description
encrypted-credentials encrypts credentials to allow them to be securely added to git repositories.
It can import encrypted settings into Django defined in a json file. Encrypted files are automatically generated.
Django settings
example
settings.json
{
"AWS_ACCESS_KEY_ID":"ABCDEFGHIJKLMNOP",
"AWS_SECRET_ACCESS_KEY":"ABCDEFGHIJKLMNOP"
}
settings.py
from encrypted_credentials.django_credentials import add_encrypted_settings
add_encrypted_settings(globals())
Upon first execution an example key will be displayed
No SETTINGS_KEY set in Environment for secure settings
A new project can use: SETTINGS_KEY=FQQcgYWCBPE8l8IbHdcNie0WARbYHeFwCl4hIL3ecF0=
set environment variable
export SETTINGS_KEY=FQQcgYWCBPE8l8IbHdcNie0WARbYHeFwCl4hIL3ecF0=
- If the
settings.json
file exists andsettings.json.enc
does not exist thensettings.json.enc
will be created.(development) - If
settings.json
andsettings.json.enc
exist then they will be compared and if differentsettings.json.enc
will be overwritten.(development) - If
settings.json
does not exist thensettings.json.enc
will be used (production)
settings.json.enc can be checked into git as it is encrypted with Fernet AES128 encryption
Credential files
get_decrypted_file
will automatically encrypt the original file and supply the decrypted data
from encrypted_credentials.encrypted_file import get_decrypted_file
get_decrypted_file('full_path/orginal.pem')
original.pem.enc can be checked into a repository
Credential files with Django
By default environment variable SETTINGS_KEY will be used as key
settings.py
CREDENTIAL_FOLDER = os.path.join(BASE_DIR, 'credentials')
CREDENTIAL_FILES = {
'gmail': 'service-account-abcd.json',
'drive': 'service-account-efgh.json',
}
service-account-abcd.json.enc
usage
from encrypted_credentials.django_credentials import get_credentials
credentials = get_credentials('gmail')
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
Built Distribution
Hashes for encrypted-credentials-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | acd1d87fe36a475d992efa073e680cda838354f002a6d592bfaf32ca56b50c70 |
|
MD5 | 4e9fad62db20809834dce281aa647d92 |
|
BLAKE2b-256 | 30f487c199b3933bd0da294d3b3ea011a4a60bb887b90c477939a240abe88c71 |
Hashes for encrypted_credentials-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1371748e677ce6f3f8ebbd18c044e574825003455415d645bd5dbe8bd680439 |
|
MD5 | 38247821be1c5173bb1d57b0a1ca84b2 |
|
BLAKE2b-256 | e8af37cb7200cc638671671b96d2ae585e210b4ea7a3c64a6d203472aa0b7e15 |