Vertx Sockjs Eventbus handler authorization

299 Views Asked by At

Im building a social platform and just started on the websocket portion. I'm having trouble understanding where to hook my auth into the Vert.x SockJsHandler. I found a code example using "SockJsServer" via vertx.createSockJsServer here but it doesnt seem like that exists in current versions:

https://github.com/michalboska/codingbeer-vertx/blob/auth-experiment/src/main/java/ch/erni/beer/vertx/HTTPServerVerticle.java

The only hook Im aware of in current version is:

return SockJSHandler.create(vertx).bridge(options) {event ->
    logger.info{ "socket event: ${event.type()}" }
    event.complete(true)
}

I see event.socket().webUser() and .webSession() exists but am unclear how/where that would get set. So my question is, will I need to create an auth handler on the initial handshake only and if so, where? If a js client needs to receive notifications for say, a message from a specific chatroom they are a member 'chat123', should I register unique handlers for chat123, or somehow iterate over event.socket().webUser() for valid ids each time?

Most vert.x docs are offline with the new site migrating to vert.x 4 so infos a bit hard to find at the moment.

0

There are 0 best solutions below