Merge pull request #9 from TronoSfera/codex/fix-bcrypt-version-attribute-error

Force passlib builtin bcrypt backend to avoid startup failures
This commit is contained in:
TronoSfera 2026-01-19 11:50:04 +03:00 committed by GitHub
commit d92aac0715
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,7 @@ from typing import Optional
from jose import JWTError, jwt
from passlib.context import CryptContext
from passlib.handlers import bcrypt as passlib_bcrypt
from fastapi import Depends, HTTPException, Request, status
from fastapi.security import OAuth2PasswordBearer
from sqlalchemy.orm import Session
@ -34,6 +35,13 @@ ACCESS_TOKEN_EXPIRE_MINUTES = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "60")
# Password hashing context
try:
passlib_bcrypt.bcrypt.set_backend("builtin")
passlib_bcrypt.bcrypt_sha256.set_backend("builtin")
except Exception:
# If the builtin backend is unavailable, fall back to the default backend.
pass
pwd_context = CryptContext(schemes=["bcrypt_sha256", "bcrypt"], deprecated="auto")