fix: truncate password to 72 bytes for bcrypt
This commit is contained in:
6
auth.py
6
auth.py
@@ -94,13 +94,13 @@ def save_users(data_dir: Path, users: dict[str, dict]):
|
||||
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
"""Hash a password."""
|
||||
return pwd_context.hash(password)
|
||||
"""Hash a password (truncate to 72 bytes for bcrypt)."""
|
||||
return pwd_context.hash(password[:72])
|
||||
|
||||
|
||||
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||
"""Verify a password against its hash."""
|
||||
return pwd_context.verify(plain_password, hashed_password)
|
||||
return pwd_context.verify(plain_password[:72], hashed_password)
|
||||
|
||||
|
||||
def create_user(data_dir: Path, username: str, password: str, email: Optional[str] = None) -> User:
|
||||
|
||||
Reference in New Issue
Block a user