fix(auth): replace passlib with direct bcrypt (compat with bcrypt>=4.0)
passlib 1.7.4 detect_wrap_bug crashes with bcrypt>=4.0 which enforces 72-byte password limit. Use bcrypt directly instead. Co-Authored-By: Paperclip <[email protected]>
This commit is contained in:
1 parent
f3d2533db5
commit
7100440294
2 files changed
+4
-6
No files matched your search
+1
-1
@@ -19,7 +19,7 @@ dependencies = [
|
||||
"pydantic>=2.10.0",
|
||||
"pydantic-settings>=2.6.0",
|
||||
"python-multipart>=0.0.17",
|
||||
"passlib[bcrypt]>=1.7.4",
|
||||
"bcrypt>=4.0.0",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from passlib.context import CryptContext
|
||||
import bcrypt
|
||||
|
||||
from forwarder.config import get_settings
|
||||
from forwarder.db.models import User
|
||||
from forwarder.db.session import get_session_factory
|
||||
|
||||
_pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
return _pwd_context.hash(password)
|
||||
return bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode()
|
||||
|
||||
|
||||
def verify_password(plain: str, hashed: str) -> bool:
|
||||
return _pwd_context.verify(plain, hashed)
|
||||
return bcrypt.checkpw(plain.encode(), hashed.encode())
|
||||
|
||||
|
||||
def ensure_admin_user() -> None:
|
||||
|
||||
Reference in new issue
Block a user