66from fastapi .security import HTTPBearer
77from fastapi .security .utils import get_authorization_scheme_param
88from jose import ExpiredSignatureError , JWTError , jwt
9- from passlib .context import CryptContext
9+ from pwdlib import PasswordHash
10+ from pwdlib .hashers .bcrypt import BcryptHasher
1011from pydantic_core import from_json
1112from sqlalchemy .ext .asyncio import AsyncSession
1213
2021from backend .utils .serializers import select_as_dict
2122from backend .utils .timezone import timezone
2223
23- pwd_context = CryptContext (schemes = ['bcrypt' ], deprecated = 'auto' )
24-
25-
2624# JWT authorizes dependency injection
2725DependsJwtAuth = Depends (HTTPBearer ())
2826
27+ password_hash = PasswordHash ((BcryptHasher (),))
28+
2929
30- def get_hash_password (password : str ) -> str :
30+ def get_hash_password (password : str , salt : bytes | None ) -> str :
3131 """
3232 Encrypt passwords using the hash algorithm
3333
3434 :param password:
35+ :param salt:
3536 :return:
3637 """
37- return pwd_context .hash (password )
38+ return password_hash .hash (password , salt = salt )
3839
3940
4041def password_verify (plain_password : str , hashed_password : str ) -> bool :
@@ -45,7 +46,7 @@ def password_verify(plain_password: str, hashed_password: str) -> bool:
4546 :param hashed_password: The hash ciphers to compare
4647 :return:
4748 """
48- return pwd_context .verify (plain_password , hashed_password )
49+ return password_hash .verify (plain_password , hashed_password )
4950
5051
5152async def create_access_token (sub : str , multi_login : bool ) -> AccessToken :
0 commit comments