You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Why
При авторизации возникает ошибка в логах, которая ни на что не влияет: AttributeError: module 'bcrypt' has no attribute '__about__' with new 4.1.1 version Ссылка на обсуждение ошибки
Причина:
This is an issue with how passlib attempts to read a version (for logging only) and fails because it's loading modules that no longer exist in bcrypt 4.1.x.
passlib seems to be abandoned and the new bcrypt doesn't work with it.
#How to do
Предложено либо даунгрейдить bcrypt до Needs to force bcrypt==4.0.1 to keep using passli
Поскольку это warning, можно его "заглушить" в настройках логгера: As the OP indicates here, passlib will work with latest bcrypt, it simply emits a warning. You should be able to silence that warning with a logging configuration. logging.getLogger('passlib').setLevel(logging.ERROR)
Либо отказаться от passlib совсем, заимствовав требуемые методы:
I resolved it by removing the passlib module and simply using the bcrypt directly for hashing and verification :
import bcrypt
# Hash a password using bcrypt
def hash_password(password):
pwd_bytes = password.encode('utf-8')
salt = bcrypt.gensalt()
hashed_password = bcrypt.hashpw(password=pwd_bytes, salt=salt)
return hashed_password
# Check if the provided password matches the stored password (hashed)
def verify_password(plain_password, hashed_password):
password_byte_enc = plain_password.encode('utf-8')
return bcrypt.checkpw(password = password_byte_enc , hashed_password = hashed_password)
Поскольку у нас используется FastApi Users, необходимо проверить можно ли безболезненно отказаться от passlib
The text was updated successfully, but these errors were encountered:
#Why
При авторизации возникает ошибка в логах, которая ни на что не влияет:
AttributeError: module 'bcrypt' has no attribute '__about__' with new 4.1.1 version
Ссылка на обсуждение ошибки
Причина:
#How to do
bcrypt
до Needs to forcebcrypt==4.0.1
to keep using passliAs the OP indicates here, passlib will work with latest bcrypt, it simply emits a warning. You should be able to silence that warning with a logging configuration
.logging.getLogger('passlib').setLevel(logging.ERROR)
passlib
совсем, заимствовав требуемые методы:FastApi Users
, необходимо проверить можно ли безболезненно отказаться отpasslib
The text was updated successfully, but these errors were encountered: