(20250102) SocketIO Tick-Out test

This commit is contained in:
2025-01-02 13:42:35 +00:00
parent 4ba4167d6a
commit 025acdccf1
+3
View File
@@ -403,12 +403,14 @@ async def on_connect(sid, environ, *args) -> bool:
return False return False
# Check the origin of the incoming request: # Check the origin of the incoming request:
printer("Checking origin.")
origin = environ.get("HTTP_ORIGIN", "???") origin = environ.get("HTTP_ORIGIN", "???")
if not origin_is_allowed(origin): if not origin_is_allowed(origin):
printer("SOCKET REJECTED: Bad origin.", sid, origin) printer("SOCKET REJECTED: Bad origin.", sid, origin)
return False return False
# Get the session token from the incoming request: # Get the session token from the incoming request:
printer("Checking session token.")
session_token = environ.get("HTTP_X_SESSION_TOKEN") session_token = environ.get("HTTP_X_SESSION_TOKEN")
if not session_token and len(args) > 0: session_token = args[0].get("X-Session-Token") if not session_token and len(args) > 0: session_token = args[0].get("X-Session-Token")
if not session_token: if not session_token:
@@ -416,6 +418,7 @@ async def on_connect(sid, environ, *args) -> bool:
return False return False
# Get the user's details from the session token: # Get the user's details from the session token:
printer("Fetching user info.")
user_info = await redis_cache.get(key = session_token) user_info = await redis_cache.get(key = session_token)
if not user_info: if not user_info:
printer("SOCKET REJECTED: Invalid session token.", sid) printer("SOCKET REJECTED: Invalid session token.", sid)