Ok, I might be doing nobody does or I might be missing something (vertx 3.1)
I was wondering if it's possible to authenticate a user using SockJS without having to have an authenticated user in a web session first.
The idea is that a previously given JWT is used once to authenticate a user for as long as that socket connection is open (So not send it on every socket request)
and use the permitted options/roles out of the box.
Normal usage is: Authenticate a user with credentials in say a http post. This results in a websession (defined by a session cookie) containing
the user. Next, a SockJS connection is established and upon upgrading the http connection to a socket connection,
the authenticated user is taken from the routingcontex/session and set as webuser for that socket connection.
Scenario:
Open a SockJS connection - No http request is executed before.
Require the first message to contain that token or otherwise close the session.
Use the token to authenticate the user and set that as the user for the socket for every subsequent call.
For every other socket call, intercept any inbound message and inject a reference to the socket session in the message header.
Any consumer retrieves this reference from the message header, uses it to retrieve the socket and the socket().user() and
can perform it's intended action based on the user's role.
(A message consumer could retrieve different record sets based on whether the user has an admin role, a user role or some other role).
It's AFAIK not possible to set the webuser anywhere from within the SockJS event bridge handler, is it?
If this is possible, is it possible to retrieve the socket's user from any message bus handler