При авторизации возникает ошибка в логах, которая ни на что не влияет:
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 :
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
совсем, заимствовав требуемые методы: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)