Skip to content

Allow access to underlying WebSocketSession with WebSocketMessageBroker config [SPR-12314] #16919

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 97596fb, f0323be

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions