mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Fix mypy error: auth handler "checkpw" internal function type mismatch (#8569)
This commit is contained in:
parent
8f27b7fde1
commit
21bb50ca3f
1
changelog.d/8569.misc
Normal file
1
changelog.d/8569.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix mypy not properly checking across the codebase, additionally, fix a typing assertion error in `handlers/auth.py`.
|
@ -1122,20 +1122,22 @@ class AuthHandler(BaseHandler):
|
|||||||
Whether self.hash(password) == stored_hash.
|
Whether self.hash(password) == stored_hash.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _do_validate_hash():
|
def _do_validate_hash(checked_hash: bytes):
|
||||||
# Normalise the Unicode in the password
|
# Normalise the Unicode in the password
|
||||||
pw = unicodedata.normalize("NFKC", password)
|
pw = unicodedata.normalize("NFKC", password)
|
||||||
|
|
||||||
return bcrypt.checkpw(
|
return bcrypt.checkpw(
|
||||||
pw.encode("utf8") + self.hs.config.password_pepper.encode("utf8"),
|
pw.encode("utf8") + self.hs.config.password_pepper.encode("utf8"),
|
||||||
stored_hash,
|
checked_hash,
|
||||||
)
|
)
|
||||||
|
|
||||||
if stored_hash:
|
if stored_hash:
|
||||||
if not isinstance(stored_hash, bytes):
|
if not isinstance(stored_hash, bytes):
|
||||||
stored_hash = stored_hash.encode("ascii")
|
stored_hash = stored_hash.encode("ascii")
|
||||||
|
|
||||||
return await defer_to_thread(self.hs.get_reactor(), _do_validate_hash)
|
return await defer_to_thread(
|
||||||
|
self.hs.get_reactor(), _do_validate_hash, stored_hash
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user