Skip to content

Commit b6369e3

Browse files
committed
fix(backend): Make authorization middleware methods properly async
- _extract_current_user: Add async keyword and split signature (Black formatting) - _build_authorization_context: Add async keyword - _get_host_id_from_scan_id: Add async keyword - _get_host_ids_from_group_id: Add async keyword All methods were already being awaited, just needed async keyword for proper asyncio semantics and Black formatter compliance.
1 parent 7d4382c commit b6369e3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

backend/app/middleware/authorization_middleware.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ def _match_pattern(self, request_path: str, pattern: str) -> bool:
302302

303303
return True
304304

305-
def _extract_current_user(self, request: Request) -> Optional[Dict[str, Any]]:
305+
async def _extract_current_user(
306+
self, request: Request
307+
) -> Optional[Dict[str, Any]]:
306308
"""
307309
Extract current user from request authentication
308310
"""
@@ -457,7 +459,7 @@ async def _extract_host_id_from_body(self, request: Request) -> Optional[str]:
457459

458460
return None
459461

460-
def _get_host_id_from_scan_id(self, scan_id: str) -> Optional[str]:
462+
async def _get_host_id_from_scan_id(self, scan_id: str) -> Optional[str]:
461463
"""
462464
Get host_id associated with a scan_id
463465
"""
@@ -483,7 +485,7 @@ def _get_host_id_from_scan_id(self, scan_id: str) -> Optional[str]:
483485
logger.error(f"Error getting host_id from scan_id {scan_id}: {e}")
484486
return None
485487

486-
def _get_host_ids_from_group_id(self, group_id: str) -> List[str]:
488+
async def _get_host_ids_from_group_id(self, group_id: str) -> List[str]:
487489
"""
488490
Get all host_ids in a host group
489491
"""
@@ -538,7 +540,7 @@ async def _extract_bulk_host_ids(
538540

539541
return []
540542

541-
def _build_authorization_context(
543+
async def _build_authorization_context(
542544
self, request: Request, current_user: Dict[str, Any]
543545
) -> AuthorizationContext:
544546
"""

0 commit comments

Comments
 (0)