fix: NCS-122 authenticate WebSocket connections via first-message auth #73

Merged
Janis merged 2 commits from fix/NCS-122-ws-token-auth into main 2026-06-17 10:42:54 +02:00
Showing only changes of commit e8ff9cd6e6 - Show all commits
@@ -66,9 +66,9 @@ class GameWebSocketResource:
@OnOpen
def onOpen(connection: WebSocketConnection): Unit =
activeGauge
val gameId = connection.pathParam("gameId")
val handler: Consumer[String] = msg => connection.sendText(msg).subscribe().`with`(_ => (), _ => ())
val subscriber = redis.pubsub(classOf[String]).subscribe(s2cTopic(gameId), handler)
val gameId = connection.pathParam("gameId")
val handler: Consumer[String] = msg => connection.sendText(msg).subscribe().`with`(_ => (), _ => ())
val subscriber = redis.pubsub(classOf[String]).subscribe(s2cTopic(gameId), handler)
connections.put(connection.id(), ConnectionMeta(gameId, subscriber, None))
connectionsOpened.increment()
pendingAuth.add(connection.id())