Description
Rob Winch opened SPR-12314 and commented
It would be nice to provide a hook that allows intercepting the HttpSession id, HttpServletRequest#getUserPrincipal(), and a reference to be able to close the WebSocket Session at the time of the handshake.
This is necessary for things like Spring Session which want to provide a mechanism to override the HttpSession since JSR-356 states:
In the case where a WebSocket endpoint is a protected resource in the web application (see Chapter 8), that is to say, requires an authorized user to access it, then the websocket implementation must ensure that the websocket endpoint does not remain connected to its peer after the underlying implementation has decided the authenticated identity is no longer valid. [WSC-7.2-3] This may happen, for example, if the user logs out
of the containing web application, or if the authentication times out or is invalidated for some other reason.In this situation, the websocket implementation must immediately close the
close status code 1008. [WSC-7.2-3]
The closest mechanism I could find to do this would be to create a HandshakeHandler. However, there doesn't appear to be a reliable way to refer to an object that can close the WebSocket Session.
Issue Links:
- Allow server-side code to send DISCONNECT messages to the broker [SPR-12288] #16893 Allow server-side code to send DISCONNECT messages to the broker