ws ticket
Build and Push Docker Image / build-and-push (push) Successful in 14s

This commit is contained in:
ciomek committed 2026-08-17 22:19:02 +02:00
1 parent a603566235
commit 7280c5dd07
5 files changed
+66 -10

No files matched your search

+10 -3
View File
@@ -34,9 +34,9 @@ class JWTAuthBackend(AuthenticationBackend):
if scheme.lower() == "bearer" and credentials:
return credentials
# Browser WebSocket APIs cannot set Authorization headers.
token = conn.query_params.get("token")
return token or None
if conn.scope["type"] == "websocket":
return conn.query_params.get("token") or None
return None
async def authenticate(
self, conn: HTTPConnection
@@ -54,6 +54,13 @@ class JWTAuthBackend(AuthenticationBackend):
if not isinstance(user_id, int):
raise AuthenticationError("Invalid or expired token")
typ = payload.get("typ")
if conn.scope["type"] == "websocket":
if typ != "ws":
raise AuthenticationError("Invalid or expired token")
elif typ != "web":
raise AuthenticationError("Invalid or expired token")
with Session(engine) as session:
user = session.exec(select(User).where(User.id == user_id)).first()