Skip to main content

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=
  1. If the settings.json file exists and settings.json.enc does not exist then settings.json.enc will be created.(development)
  2. If settings.json and settings.json.enc exist then they will be compared and if different settings.json.enc will be overwritten.(development)
  3. If settings.json does not exist then settings.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

encrypted-credentials-0.0.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

encrypted_credentials-0.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file encrypted-credentials-0.0.2.tar.gz.

File metadata

  • Download URL: encrypted-credentials-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.3

File hashes

Hashes for encrypted-credentials-0.0.2.tar.gz
Algorithm Hash digest
SHA256 acd1d87fe36a475d992efa073e680cda838354f002a6d592bfaf32ca56b50c70
MD5 4e9fad62db20809834dce281aa647d92
BLAKE2b-256 30f487c199b3933bd0da294d3b3ea011a4a60bb887b90c477939a240abe88c71

See more details on using hashes here.

File details

Details for the file encrypted_credentials-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: encrypted_credentials-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.3

File hashes

Hashes for encrypted_credentials-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d1371748e677ce6f3f8ebbd18c044e574825003455415d645bd5dbe8bd680439
MD5 38247821be1c5173bb1d57b0a1ca84b2
BLAKE2b-256 e8af37cb7200cc638671671b96d2ae585e210b4ea7a3c64a6d203472aa0b7e15

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page