title: Websocket API security when accessing from a browser
body: <p>Wondering about my security approach.</p>
  <p>We have a web server with some kind of backend, and a JS frontend.
  Users have to login through the frontend, with regular GET/POST requests, they get a HTTP-only session cookie set as well as a particular &quot;wstoken&quot; string that is available to the JS (by setting it with <code>&lt;script&gt;wstoken = 'xxx';&lt;/script&gt;</code></p>
  <p>The frontend then opens a WS connection to the API server and sends an authentication request with the wstoken. If the wstoken matches what we have for the user in the DB, we accept the authentication request and consider that WS connection to be authed to that user.</p>
  <p>I'm wondering if I'm doing it right.</p>