diff --git a/backend/app/core/security.py b/backend/app/core/security.py index 419c80f..62d2733 100644 --- a/backend/app/core/security.py +++ b/backend/app/core/security.py @@ -6,8 +6,8 @@ import hashlib import secrets from datetime import datetime, timedelta from typing import Optional, Dict, Any +import bcrypt from jose import JWTError, jwt -from passlib.context import CryptContext from cryptography.fernet import Fernet from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC @@ -15,18 +15,17 @@ import base64 from app.core.config import settings -# Password hashing context -pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") - def verify_password(plain_password: str, hashed_password: str) -> bool: """Verify a password against its 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: """Generate password hash""" - return pwd_context.hash(password) + return bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8") def create_access_token( diff --git a/backend/requirements.txt b/backend/requirements.txt index aba2bfd..75e6945 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -12,7 +12,7 @@ asyncpg==0.29.0 # Authentication python-jose[cryptography]==3.3.0 -passlib[bcrypt]==1.7.4 +bcrypt==4.3.0 python-multipart==0.0.22 # Updated: Fixed multiple vulnerabilities (was 0.0.6) authlib==1.6.9 # Updated: Fixed OIDC hash binding, JWE RSA1_5 padding oracle, alg:none bypass, JWK header injection (was 1.6.6) httpx==0.26.0