❯ Encrypted fields in Django
- 📍 Overview
- 👾 Features
- 📁 Project Structure
- 🚀 Getting Started
- 📌 Project Roadmap
- 🔰 Contributing
- 🎗 License
- 🙌 Acknowledgments
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
.
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.
Before getting started with django-secrets-fields, ensure your runtime environment meets the following requirements:
- Programming Language: Python 3.10+
Install django-secrets-fields:
pip install django-secrets-fields
To use backend that requires AWS install using:
pip install django-secrets-fields[aws]
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()
-
Symmetric backend
:Add symmetric encryption backend. -
Asymmetric backedn
: Add asymmetric encryption backend. -
AWS Parameter Store
: Add AWS Parameter Store backend.
- 💬 Join the Discussions: Share your insights, provide feedback, or ask questions.
- 🐛 Report Issues: Submit bugs found or log feature requests for the
django-secrets-fields
project. - 💡 Submit Pull Requests: Review open PRs, and submit your own PRs.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your github account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/ryan-shaw/django-secrets-fields
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to github: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
This project is protected under the MIT License. For more details, refer to the LICENSE file.