diff --git a/app/system/impl/native_python.py b/app/system/impl/native_python.py index c1a025a..dd154a1 100644 --- a/app/system/impl/native_python.py +++ b/app/system/impl/native_python.py @@ -1,7 +1,7 @@ import logging -import secrets from typing import Dict +import bcrypt import psutil from decouple import config from fastapi import HTTPException, status @@ -64,8 +64,8 @@ async def get_connection_info(self) -> ConnectionInfo: return ConnectionInfo() async def login(self, i: LoginInput) -> Dict[str, str]: - matches = secrets.compare_digest(i.password, config("login_password", cast=str)) - if matches: + hashed_password = config("login_password", cast=str) + if bcrypt.checkpw(i.password.encode("utf-8"), hashed_password.encode("utf-8")): return sign_jwt() raise HTTPException( diff --git a/app/system/router.py b/app/system/router.py index 6c0943c..19f2d6e 100644 --- a/app/system/router.py +++ b/app/system/router.py @@ -170,7 +170,9 @@ async def hw_info_sub(request: Request): async def get_system_health( verbose: bool = Query( False, - description="Returns info about each subsytem running on this node if true. Currently not implemented.", + description="""Returns info about each + subsytem running on this node if + true. Currently not implemented.""", ), ) -> SystemHealthInfo: return await system_health(verbose) diff --git a/tests/repositories/test_system.py b/tests/repositories/test_system.py index ebb07ff..f49e010 100644 --- a/tests/repositories/test_system.py +++ b/tests/repositories/test_system.py @@ -16,7 +16,7 @@ async def fake_match_pw_positive(_): ) res = await sys.login(i=LoginInput(password="12345678")) - assert type(res) is dict + assert isinstance(res, dict) assert res.startswith("ey") is True async def fake_match_pw_negative(_):