From 13c49aebfd9da40471c16e1b186a864505ffb23b Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 27 Jan 2026 23:16:17 +0000 Subject: [PATCH] Remove unnecessary use of async now that db access doesn't need awaiting. --- paskia/authsession.py | 6 +++--- paskia/fastapi/api.py | 4 ++-- paskia/fastapi/user.py | 2 +- paskia/fastapi/ws.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/paskia/authsession.py b/paskia/authsession.py index 4169394..e05b543 100644 --- a/paskia/authsession.py +++ b/paskia/authsession.py @@ -30,7 +30,7 @@ def reset_expires() -> datetime: return datetime.now(timezone.utc) + RESET_LIFETIME -async def get_reset(token: str) -> "ResetToken": +def get_reset(token: str) -> "ResetToken": """Validate a credential reset token.""" record = db.get_reset_token(token) @@ -39,7 +39,7 @@ async def get_reset(token: str) -> "ResetToken": raise ValueError("This authentication link is no longer valid.") -async def refresh_session_token(token: str, *, ip: str, user_agent: str): +def refresh_session_token(token: str, *, ip: str, user_agent: str): """Refresh a session extending its expiry.""" session_record = db.data().sessions.get(token) if not session_record: @@ -54,7 +54,7 @@ async def refresh_session_token(token: str, *, ip: str, user_agent: str): raise ValueError("Session not found or expired") -async def delete_credential(credential_uuid: UUID, auth: str, host: str | None = None): +def delete_credential(credential_uuid: UUID, auth: str, host: str | None = None): """Delete a specific credential for the current user.""" ctx = db.get_session_context(auth, hostutil.normalize_host(host)) if not ctx: diff --git a/paskia/fastapi/api.py b/paskia/fastapi/api.py index 730a968..237e48a 100644 --- a/paskia/fastapi/api.py +++ b/paskia/fastapi/api.py @@ -93,7 +93,7 @@ async def validate_token( consumed = EXPIRES - (ctx.session.expiry - datetime.now(timezone.utc)) if not timedelta(0) < consumed < _REFRESH_INTERVAL: try: - await refresh_session_token( + refresh_session_token( auth, ip=request.client.host if request.client else "", user_agent=request.headers.get("user-agent") or "", @@ -119,7 +119,7 @@ async def token_info(credentials=Depends(bearer_auth)): if not passphrase.is_well_formed(token): raise HTTPException(400, "Invalid token format") try: - reset_token = await get_reset(token) + reset_token = get_reset(token) except ValueError as e: raise HTTPException(401, str(e)) diff --git a/paskia/fastapi/user.py b/paskia/fastapi/user.py index 304e2b6..2062729 100644 --- a/paskia/fastapi/user.py +++ b/paskia/fastapi/user.py @@ -111,7 +111,7 @@ async def api_delete_credential( # Require recent authentication for sensitive operation await authz.verify(auth, [], host=request.headers.get("host"), max_age="5m") try: - await delete_credential(uuid, auth, host=request.headers.get("host")) + delete_credential(uuid, auth, host=request.headers.get("host")) except ValueError as e: raise authz.AuthException( status_code=401, detail="Session expired", mode="login" diff --git a/paskia/fastapi/ws.py b/paskia/fastapi/ws.py index 02a398a..605e066 100644 --- a/paskia/fastapi/ws.py +++ b/paskia/fastapi/ws.py @@ -37,7 +37,7 @@ async def websocket_register_add( raise ValueError( f"The reset link for {passkey.instance.rp_name} is invalid or has expired" ) - s = await get_reset(reset) + s = get_reset(reset) user_uuid = s.user else: # Require recent authentication for adding a new passkey