Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8k
-
First Check
Commit to Help
Example Codefrompasslib.contextimportCryptContextpwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")hashed_password=pwd_context.hash(user.password) DescriptionIt won't cause a actually problem but a warning about cannot get bcrypt's version(just for logging). I suggest that the official docs may need to change some contexts such as thishttps://fastapi.tiangolo.com/tutorial/security/oauth2-jwt/ to avoid the using of passlib since it haven't been maintenanced for a long time. Thanks. Operating SystemWindows Operating System DetailsNo response FastAPI Version0.111.0 Pydantic Version2.7.4 Python VersionPython 3.10.2 Additional ContextNo response |
BetaWas this translation helpful?Give feedback.
All reactions
@dann2333 Required changes to the docs example to usebcrypt directly are minimal. Just need to replace this part of the code
pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")oauth2_scheme=OAuth2PasswordBearer(tokenUrl="token")app=FastAPI()defverify_password(plain_password,hashed_password):returnpwd_context.verify(plain_password,hashed_password)defget_password_hash(password):returnpwd_context.hash(password)
with this
# from passlib.context import CryptContext <- remove passlib from importsimportbcryptoauth2_scheme=OAuth2PasswordBearer(tokenUrl="token")app=FastAPI()defverify_password(plain_password,hashed_password):returnbc…
Replies: 3 comments 8 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
please check this :canonical/cloud-init#4791 |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi, it's 3 months passed and the new version of passlib seems still not released. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi, passlib has not been updated yet, so it is recommended that fastapi update the documentation and abandon passlib for now |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
fastapi seems really need to change some... passlib still no update... |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@dann2333 Required changes to the docs example to usebcrypt directly are minimal. Just need to replace this part of the code pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")oauth2_scheme=OAuth2PasswordBearer(tokenUrl="token")app=FastAPI()defverify_password(plain_password,hashed_password):returnpwd_context.verify(plain_password,hashed_password)defget_password_hash(password):returnpwd_context.hash(password) with this # from passlib.context import CryptContext <- remove passlib from importsimportbcryptoauth2_scheme=OAuth2PasswordBearer(tokenUrl="token")app=FastAPI()defverify_password(plain_password,hashed_password):returnbcrypt.checkpw(bytes(plain_password,encoding="utf-8"),bytes(hashed_password,encoding="utf-8"), )defget_password_hash(password):returnbcrypt.hashpw(bytes(password,encoding="utf-8"),bcrypt.gensalt(), ) Sorry if I missed your point. |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 12🚀 1
-
|
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Came here from the OAuth2 chapter from the docs |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Here's a small example to get the error: frompasslib.contextimportCryptContextCryptContext(schemes=["bcrypt"],deprecated="auto").dummy_verify() |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Same for me. In debug it behaves well but on server it started to show this error message |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
We have updated docs to use |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 2
-
Thanks@YuriiMotov ! I saw the update to the docs two days ago and immediately adopted it into my codebase |
BetaWas this translation helpful?Give feedback.