瀏覽代碼

Fix mypy error: auth handler "checkpw" internal function type mismatch (#8569)

tags/v1.22.0rc1
Jonathan de Jong 3 年之前
committed by GitHub
父節點
當前提交
21bb50ca3f
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 3 個文件被更改,包括 6 次插入4 次删除
  1. +1
    -0
      changelog.d/8569.misc
  2. +5
    -3
      synapse/handlers/auth.py
  3. +0
    -1
      tox.ini

+ 1
- 0
changelog.d/8569.misc 查看文件

@@ -0,0 +1 @@
Fix mypy not properly checking across the codebase, additionally, fix a typing assertion error in `handlers/auth.py`.

+ 5
- 3
synapse/handlers/auth.py 查看文件

@@ -1122,20 +1122,22 @@ class AuthHandler(BaseHandler):
Whether self.hash(password) == stored_hash.
"""

def _do_validate_hash():
def _do_validate_hash(checked_hash: bytes):
# Normalise the Unicode in the password
pw = unicodedata.normalize("NFKC", password)

return bcrypt.checkpw(
pw.encode("utf8") + self.hs.config.password_pepper.encode("utf8"),
stored_hash,
checked_hash,
)

if stored_hash:
if not isinstance(stored_hash, bytes):
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:
return False



+ 0
- 1
tox.ini 查看文件

@@ -158,7 +158,6 @@ commands=
coverage html

[testenv:mypy]
skip_install = True
deps =
{[base]deps}
mypy==0.782


Loading…
取消
儲存