Skip to content

Commit 7c70297

Browse files
committed
feature: Replace passlib by pwdlib
1 parent 2e107b4 commit 7c70297

3 files changed

Lines changed: 159 additions & 81 deletions

File tree

backend/app/core/security.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from typing import Any
33

44
import jwt
5-
from passlib.context import CryptContext
5+
from pwdlib import PasswordHash
66

77
from app.core.config import settings
88

9-
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
9+
password_hash = PasswordHash.recommended()
1010

1111

1212
ALGORITHM = "HS256"
@@ -20,8 +20,8 @@ def create_access_token(subject: str | Any, expires_delta: timedelta) -> str:
2020

2121

2222
def verify_password(plain_password: str, hashed_password: str) -> bool:
23-
return pwd_context.verify(plain_password, hashed_password)
23+
return password_hash.verify(plain_password, hashed_password)
2424

2525

2626
def get_password_hash(password: str) -> str:
27-
return pwd_context.hash(password)
27+
return password_hash.hash(password)

backend/pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ dependencies = [
77
"fastapi[standard]<1.0.0,>=0.114.2",
88
"python-multipart<1.0.0,>=0.0.7",
99
"email-validator<3.0.0.0,>=2.1.0.post1",
10-
"passlib[bcrypt]<2.0.0,>=1.7.4",
1110
"tenacity<9.0.0,>=8.2.3",
1211
"pydantic>2.0",
1312
"emails<1.0,>=0.6",
@@ -16,11 +15,10 @@ dependencies = [
1615
"httpx<1.0.0,>=0.25.1",
1716
"psycopg[binary]<4.0.0,>=3.1.13",
1817
"sqlmodel<1.0.0,>=0.0.21",
19-
# Pin bcrypt until passlib supports the latest
20-
"bcrypt==4.3.0",
2118
"pydantic-settings<3.0.0,>=2.2.1",
2219
"sentry-sdk[fastapi]<2.0.0,>=1.40.6",
2320
"pyjwt<3.0.0,>=2.8.0",
21+
"pwdlib[argon2]>=0.2.1",
2422
]
2523

2624
[tool.uv]

0 commit comments

Comments
 (0)