Add encrypting backend mixin and mix it in with Django's built-in backends #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is my first attempt at this, so feedback and criticism is more than welcome!
This is extremely similar to
email_extras.utils.send_mail, but it's a mixin for mail backends.The main problem I have with django-email-extras is that third-party app developers have to explicitly opt-in to using it by calling our
send_mailfunction. I am using django-accounts and django-allauth to handle user registration/login/forgotten passwords, and they use Django's built-in one fromdjango.core.mail.I think encryption should be as easy to implement and use as possible (while still remaining actually secure), so this is an attempt in that direction. With this backend configured all mail Django sends will be sent through this backend, and opportunistically encrypted along the way (if the user has uploaded a key).
I also mixed it in with Django's built-in backends, so there's
Encrypting*EmailBackendfor theConsole,Locmem,Filebased, andSmtpbackends.I am explicitly not adding code to upload the key to keyservers because python-gnupg does not yet support generating key revocation certificates, so I don't want users to upload keys they can't easily revoke.I added code to the newemail_signing_keymanagement command to automatically upload the key to one of more specified keyservers.TODO:
SIGNING_KEY_FINGERPRINTspecified a key that doesn't existEMAIL_EXTRAS_SIGNING_KEY_DATAFire up server, browse to admin for keysHit the "Generate signing key" buttonRun theemail_signing_keycommand to generate a signing keyEMAIL_EXTRAS_SIGNING_KEY_FINGERPRINTto copied fingerprintEdit: Thought of more/better ways to go about things.