mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
update doveauth hashing
This commit is contained in:
committed by
missytake
parent
b5d0b0ad9a
commit
9515a37687
@@ -23,15 +23,11 @@ class UnknownCommand(ValueError):
|
|||||||
|
|
||||||
def encrypt_password(password: str):
|
def encrypt_password(password: str):
|
||||||
# https://doc.dovecot.org/configuration_manual/authentication/password_schemes/
|
# https://doc.dovecot.org/configuration_manual/authentication/password_schemes/
|
||||||
salt = os.urandom(16)
|
sha512_hash = hashlib.sha512()
|
||||||
iterations = 100000
|
sha512_hash.update(password.encode('utf-8'))
|
||||||
hash_obj = hashlib.pbkdf2_hmac('sha512', password.encode(), salt, iterations)
|
hex_dig = sha512_hash.hexdigest()
|
||||||
hash_hex = hash_obj.hex()
|
|
||||||
salt_hex = salt.hex()
|
|
||||||
combined_hash = f"${iterations}${salt_hex}${hash_hex}"
|
|
||||||
|
|
||||||
return "{SHA512-CRYPT}" + combined_hash
|
return "{SHA512-CRYPT}$6$" + hex_dig
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def is_allowed_to_create(config: Config, user, cleartext_password) -> bool:
|
def is_allowed_to_create(config: Config, user, cleartext_password) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user