Skip to content

Commit 873bc55

Browse files
authored
Merge pull request #320 from rozari0/pwdlib
refactor: migrate from passlib to pwdlib
2 parents a841086 + d75b6e7 commit 873bc55

3 files changed

Lines changed: 341 additions & 334 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies = [
1515
"bcrypt>=4.2.0",
1616
"fastapi>=0.115.4",
1717
"gunicorn>=23.0.0",
18-
"passlib>=1.7.4",
18+
"pwdlib[bcrypt]>=0.3.0",
1919
"python-jose[cryptography]>=3.3.0",
2020
"python-multipart>=0.0.17",
2121
"uvicorn>=0.32.0",

svc/core/auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from fastapi import APIRouter, Depends, HTTPException
77
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
88
from jose import JWTError, jwt
9-
from passlib.context import CryptContext
9+
from pwdlib import PasswordHash
10+
from pwdlib.hashers.bcrypt import BcryptHasher
1011
from pydantic import BaseModel
1112

1213
from svc.core import config
@@ -30,7 +31,7 @@ class UserInDB(User):
3031
hashed_password: str
3132

3233

33-
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
34+
pwd_context = PasswordHash([BcryptHasher()])
3435
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token")
3536
router = APIRouter()
3637

0 commit comments

Comments
 (0)