From 6c91c1db05d313c1e373cf06eb4e317f802c2a02 Mon Sep 17 00:00:00 2001 From: Rbinning Date: Mon, 14 Oct 2024 20:18:40 -0500 Subject: [PATCH] fix hardcoded localhost to use .env --- backend/managers/AuthManager.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/managers/AuthManager.py b/backend/managers/AuthManager.py index e48a118f..0c1008e0 100644 --- a/backend/managers/AuthManager.py +++ b/backend/managers/AuthManager.py @@ -121,10 +121,12 @@ async def registration_options(self, email_id: str): return challenge, options_to_json(options) - async def registrationResponse(self, challenge: str, email_id: str,user_id: str, response): + async def registrationResponse(self, challenge: str, email_id: str, user_id: str, response): async with db_session_context() as session: - expected_origin = "https://localhost:8443" - expected_rpid = "localhost" + host = get_env_key('PAIOS_HOST', 'localhost') + port = get_env_key('PAIOS_PORT', '8443') + expected_origin = f"https://{host}:{port}" + expected_rpid = host res = verify_registration_response(credential=response, expected_challenge=base64url_to_bytes(challenge), @@ -196,10 +198,13 @@ async def signinRequestOptions(self, email_id: str): challenge = base64.urlsafe_b64encode(options.challenge).decode("utf-8").rstrip("=") return challenge, options_to_json(options) - async def signinResponse(self, challenge: str,email_id:str, response): + async def signinResponse(self, challenge: str, email_id:str, response): async with db_session_context() as session: - expected_origin = "https://localhost:8443" - expected_rpid = "localhost" + host = get_env_key('PAIOS_HOST', 'localhost') + port = get_env_key('PAIOS_PORT', '8443') + expected_origin = f"https://{host}:{port}" + expected_rpid = host + credential_result = await session.execute(select(Cred).where(Cred.id == response["id"])) credential = credential_result.scalar_one_or_none()