Skip to main content

Django encrypted model field that fetches the value from multiple sources

Project description

DJANGO-SECRETS-FIELDS

❯ Encrypted fields in Django

license last-commit code-cov


🔗 Table of Contents


📍 Overview

Django encrypted fields with support for multiple backends, currently supports symmetric encryption using Fernet and AWS Secrets Manager. Two fields types are currently supported, SecretTextField and SecretJSONField.


👾 Features

  • Symmetric Encryption: Encrypt fields using Fernet encryption.
  • AWS Secrets Manager: Use AWS Secrets Manager as a backend for storing secrets.
  • Multiple Backends: Use multiple backends for different fields.

🚀 Getting Started

☑️ Prerequisites

Before getting started with django-secrets-fields, ensure your runtime environment meets the following requirements:

  • Programming Language: Python 3.10+

⚙️ Installation

Install django-secrets-fields:

pip install django-secrets-fields

To use backend that requires AWS install using:

pip install django-secrets-fields[aws]

🤖 Usage

settings.py

DJANGO_SECRETS_FIELDS = {
    "default": {
        "backend": "secrets_fields.backends.encrypted.EncryptedBackend",
        "encryption_key": b"<fernet key>",
    },
    "aws": {
        "backend": "secrets_fields.backends.secretsmanager.SecretsManagerBackend",
        "prefix": "/path/",
    },
}

# If you need to migrate from plaintext fields, set this value to True and run `manage.py migrate_encrypted` - this could take a long time depending on the number of models and instances.
DJANGO_SECRETS_FIELDS_MIGRATE = True

A Fernet key can be generated using the following command:

python manage.py generate_fernet_key

models.py

from django.db import models
from secrets_fields.fields import SecretJSONField, SecretTextField


class MyModel(models.Model):
	secret_text = SecretTextField(backend="aws")
	secret_json = SecretJSONField()

📌 Project Roadmap

  • Symmetric backend: Add symmetric encryption backend.
  • Asymmetric backedn: Add asymmetric encryption backend.
  • AWS Parameter Store: Add AWS Parameter Store backend.

🔰 Contributing

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/ryan-shaw/django-secrets-fields
    
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
    
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
    
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
    
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


🎗 License

This project is protected under the MIT License. For more details, refer to the LICENSE file.


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

django_secrets_fields-1.0.5.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_secrets_fields-1.0.5-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file django_secrets_fields-1.0.5.tar.gz.

File metadata

  • Download URL: django_secrets_fields-1.0.5.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for django_secrets_fields-1.0.5.tar.gz
Algorithm Hash digest
SHA256 c56b864387c806b00401e68657c0ba8c590888cbf496580ca21fe13b49521d9d
MD5 4fde0825479f0aec0777eee8199752b2
BLAKE2b-256 7df14896b00da4cba6e1731b6d5d5cc0bb7d088864e268c5ac7e099bd66c06c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_secrets_fields-1.0.5.tar.gz:

Publisher: publish.yml on ryan-shaw/django-secrets-fields

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_secrets_fields-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_secrets_fields-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b80386d6184ce85de1349b14adce8515ad6eaa6182ad9d67f677c50e4eca7b76
MD5 98af525535603bbc6036b6bb3ae0e9e5
BLAKE2b-256 8c9beb539ab7edc0bd8b45ff11d2a11e58797b1dd50e45a0d12ee32c3e6576bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_secrets_fields-1.0.5-py3-none-any.whl:

Publisher: publish.yml on ryan-shaw/django-secrets-fields

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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