Skip to content

Commit

Permalink
wrap argon2 verify with exception catcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Peschke committed Nov 30, 2023
1 parent ead954f commit 1727053
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion auth/libraries/pip-auth/authlib/hashing_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ def hash(self, to_hash: str, hash_reference: Optional[str] = None) -> str:

def verify(self, hash: str, password: str) -> bool:
ph = argon2.PasswordHasher()
return ph.verify(hash, password)
try:
return ph.verify(hash, password)
except (
argon2.exceptions.VerifyMismatchError,
argon2.exceptions.VerificationError,
argon2.exceptions.InvalidHashError,
):
return False

0 comments on commit 1727053

Please sign in to comment.