full-stack-fastapi-template icon indicating copy to clipboard operation
full-stack-fastapi-template copied to clipboard

♻️ Replace `passlib` with `pwdlib`

Open 4sushi opened this issue 3 months ago • 2 comments

Replace hash library passlib by pwdlib, since passlib is not stable. Pwdlib is used by fastapi.

Related PR

https://github.com/fastapi/full-stack-fastapi-template/pull/1539

4sushi avatar Oct 20 '25 09:10 4sushi

It should be very straightforward to keep bcrypt support based on to the docs @YuriiMotov shared, @4sushi 😄

You just need to update pyproject.toml:

"pwdlib[argon2,bcrypt]>=0.2.1",

And in security.py, import and configure both hashers:

from pwdlib import PasswordHash
from pwdlib.hashers.argon2 import Argon2Hasher
from pwdlib.hashers.bcrypt import BcryptHasher

password_hash = PasswordHash(
    (
        Argon2Hasher(),
        BcryptHasher(),
    )
)

All tests will pass:

image

ceb10n avatar Nov 16 '25 17:11 ceb10n

Sorry I was pretty busy, thanks @ceb10n for completing the PR.

4sushi avatar Nov 28 '25 19:11 4sushi