diff --git a/backend/auth.py b/backend/auth.py index 1e521b5..e671d25 100644 --- a/backend/auth.py +++ b/backend/auth.py @@ -1,16 +1,14 @@ -from passlib.context import CryptContext +import bcrypt import pyotp -# Configuration du hachage (bcrypt) -pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") - def verify_password(plain_password: str, hashed_password: str) -> bool: """Vérifie si le mot de passe en clair correspond au hash.""" - return pwd_context.verify(plain_password, hashed_password) + return bcrypt.checkpw(plain_password.encode('utf-8'), hashed_password.encode('utf-8')) def get_password_hash(password: str) -> str: - """Génère le hash d'un mot de passe.""" - return pwd_context.hash(password) + """Génère le hash sécurisé d'un mot de passe.""" + salt = bcrypt.gensalt() + return bcrypt.hashpw(password.encode('utf-8'), salt).decode('utf-8') def generate_totp_secret() -> str: """Génère un secret aléatoire pour l'application 2FA (Authenticator, Keepassium).""" diff --git a/requirements.txt b/requirements.txt index 0390673..bba0705 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,5 +8,5 @@ qrcode psutil python-dotenv python-multipart -passlib[bcrypt] +bcrypt email-validator \ No newline at end of file