Skip to content

Commit

Permalink
Ba2026 argon2 exception catched (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-peschke committed Nov 30, 2023
1 parent 6a83d62 commit da6d2a9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions auth/libraries/pip-auth/authlib/hashing_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
import argon2


HASH_WITH_SALT_LENGTH = 152


class HashingHandler:
def hash(self, to_hash: str, hash_reference: Optional[str] = None) -> str:
ph = argon2.PasswordHasher()
return ph.hash(to_hash)

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 da6d2a9

Please sign in to comment.