dara-core 1.15.4__py3-none-any.whl → 1.15.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,6 +33,7 @@ from jwt import DecodeError
33
33
  from pydantic import BaseModel, Field, parse_obj_as
34
34
  from starlette.websockets import WebSocket, WebSocketDisconnect
35
35
 
36
+ from dara.core.auth.base import BaseAuthConfig
36
37
  from dara.core.auth.definitions import AuthError, TokenData
37
38
  from dara.core.auth.utils import decode_token
38
39
  from dara.core.logging import dev_logger, eng_logger
@@ -429,6 +430,7 @@ async def ws_handler(websocket: WebSocket, token: Optional[str] = Query(default=
429
430
 
430
431
  from dara.core.auth.definitions import ID_TOKEN, SESSION_ID, USER, UserData
431
432
  from dara.core.internal.registries import (
433
+ auth_registry,
432
434
  pending_tokens_registry,
433
435
  sessions_registry,
434
436
  utils_registry,
@@ -439,7 +441,16 @@ async def ws_handler(websocket: WebSocket, token: Optional[str] = Query(default=
439
441
  channel = str(uuid.uuid4())
440
442
 
441
443
  try:
442
- token_content: TokenData = decode_token(token)
444
+ auth_config: BaseAuthConfig = auth_registry.get('auth_config')
445
+
446
+ # Handle verify_token being async
447
+ verifier = auth_config.verify_token
448
+
449
+ if inspect.iscoroutinefunction(verifier):
450
+ token_content = await verifier(token)
451
+ else:
452
+ token_content = verifier(token)
453
+
443
454
  except DecodeError as err:
444
455
  raise WebSocketException(code=403, reason='Invalid or expired token') from err
445
456
  except AuthError as err: