diff --git a/chatmaild/src/chatmaild/doveauth.py b/chatmaild/src/chatmaild/doveauth.py index b3956833..a1e9db25 100644 --- a/chatmaild/src/chatmaild/doveauth.py +++ b/chatmaild/src/chatmaild/doveauth.py @@ -4,6 +4,7 @@ import logging import os import sys import time +import passlib from pathlib import Path from socketserver import ( StreamRequestHandler, @@ -23,11 +24,8 @@ class UnknownCommand(ValueError): def encrypt_password(password: str): # https://doc.dovecot.org/configuration_manual/authentication/password_schemes/ - sha512_hash = hashlib.sha512() - sha512_hash.update(password.encode('utf-8')) - hex_dig = sha512_hash.hexdigest() - - return "{SHA512-CRYPT}$6$" + hex_dig + pw = passlib.hash.sha512_crypt.hash(password).split("$") + return "{SHA512-CRYPT}$" + pw[1] + "$" + pw[3] + "ยง" + pw[4] def is_allowed_to_create(config: Config, user, cleartext_password) -> bool: diff --git a/cmdeploy/pyproject.toml b/cmdeploy/pyproject.toml index 807b2453..d7ab14e0 100644 --- a/cmdeploy/pyproject.toml +++ b/cmdeploy/pyproject.toml @@ -19,6 +19,7 @@ dependencies = [ "pytest", "pytest-xdist", "imap_tools", + "passlib", ] [project.scripts]