mirror of
https://github.com/modoboa/modoboa.git
synced 2026-04-26 01:16:01 +03:00
[PR #1357] [MERGED] refactor cryptutils #2208
Labels
No labels
bug
bug
dependencies
design
documentation
duplicate
enhancement
enhancement
enhancement
feedback-needed
help-needed
help-needed
installer
invalid
looking-for-sponsors
modoboa-contacts
new-ui
new-ui
pr
pull-request
pyconfr
python
question
security
stale
webmail
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/modoboa-modoboa#2208
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/modoboa/modoboa/pull/1357
Author: @ghost
Created: 1/15/2018
Status: ✅ Merged
Merged: 1/18/2018
Merged by: @tonioo
Base:
master← Head:feature/refactor-cryptutils📝 Commits (1)
e8ab4e2refactor cryptutils📊 Changes
2 files changed (+73 additions, -44 deletions)
View changed files
📝
modoboa/lib/cryptutils.py(+35 -44)➕
modoboa/lib/tests/test_cryptutils.py(+38 -0)📄 Description
Cryptography can be a black art, rather than rolling our own crypto
functions use the ones provided by the Python Cryptography module.
encrypt()anddecrypt()ECB is insecure and the Python Cryptography module recommends[1]
against using it. The Python Cryptography module offers Fernet[2]
for encrypting values using a secret_key.
Djangos
settings.SECRET_KEYexists for things like encryptingpasswords, use it instead of Modoboas own
secret_key[3].settings.SECRET_KEYis truncated to 32 characters as Fernet requiresa key 32 characters long.
random_key()uses Dangos get_random_string() method, the samecode used to generate settings.SECRET_KEY
add tests for cryptutil methods
[1] https://cryptography.io/en/latest/hazmat/primitives/symmetric-encryption/?highlight=ecb#insecure-modes
[2] https://cryptography.io/en/latest/fernet/
[3] It's my intention to remove Modoboas
secret_keyas it can be replaced by Djangossettings.SECRET_KEY, I just need to make sure it won't break modoboa-pdfcredentials as it also uses it.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.