mirror of
https://github.com/chatmail/relay.git
synced 2026-05-20 04:48:06 +00:00
replace crypt with passlib
This commit is contained in:
committed by
missytake
parent
3d8ac6b598
commit
b951ec12c5
@@ -4,6 +4,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import passlib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from socketserver import (
|
from socketserver import (
|
||||||
StreamRequestHandler,
|
StreamRequestHandler,
|
||||||
@@ -23,11 +24,8 @@ 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/
|
||||||
sha512_hash = hashlib.sha512()
|
pw = passlib.hash.sha512_crypt.hash(password).split("$")
|
||||||
sha512_hash.update(password.encode('utf-8'))
|
return "{SHA512-CRYPT}$" + pw[1] + "$" + pw[3] + "§" + pw[4]
|
||||||
hex_dig = sha512_hash.hexdigest()
|
|
||||||
|
|
||||||
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:
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ dependencies = [
|
|||||||
"pytest",
|
"pytest",
|
||||||
"pytest-xdist",
|
"pytest-xdist",
|
||||||
"imap_tools",
|
"imap_tools",
|
||||||
|
"passlib",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
|
|||||||
Reference in New Issue
Block a user