I have a scenario where a user establishes a WebSocket connection first, and then I need to authenticate that user. The flow I am considering is as follows:
The client establishes a WebSocket connection with the server. After the connection is established, the client sends an authentication message containing the authentication token. The server verifies the token. Upon successful verification, the server associates the specific WebSocket connection with the user ID extracted from the token. [I need guidance on this part] Here’s how I am currently handling this:
When accepting the connection, I tag the connection with a UUID. Upon authentication, I update the KV store with the UUID and the user associated with it. I use
getTags
getTags
to fetch the user ID information. I want to make sure I am correctly associating the WebSocket connection with the user ID for subsequent operations. Is there anything you would recommend changing or improving in this approach?