kbss-cvut / termit

An advanced SKOS terminology manager linking concepts to their definitions in documents
GNU General Public License v3.0
8 stars 9 forks source link

WebSockets #290

Closed lukaskabc closed 2 weeks ago

lukaskabc commented 2 weeks ago

Implementation of WebSockets on HTTP(S) endpoint /termit/ws using STOMP protocol.

WebSockets will be used in future PR addressing application performance (dev branch).

Authentication

WebSocket API in browsers does not allow setting custom headers for WS handshake (HTTP request for protocol upgrade), which leaves us with three options for how to implement authentication using the JWT token:

  1. save the token as a cookie, which will be sent by the browser automatically (hopefully)
  2. send the token as a query parameter
  3. send it with a STOMP CONNECT message

Currently implemented as option 3, which is most reliable.
This means any WebSocket connection is accepted, and the client has limited time (15s) to send a STOMP CONNECT message with a valid JWT token. Otherwise, the connection is closed.

  1. might face issues with cookies access and browser compatibility, but it should be possible to implement for better security of the ws endpoint in the future
  2. JWT would be part of history and logs, which is unacceptable

Changes

Tests

Prepared two test runners for WebSocket testing.

Required changes (TODO)