Skip to content

Improve web socket header support [SPR-13170] #17761

Closed
@spring-projects-issues

Description

@spring-projects-issues

Bobby Warner opened SPR-13170 and commented

There is no way to access any of the web socket STOMP headers in the Spring handshake handler. This is required to support custom authentication / authorization schemes.

For example, given a JS file like this:

var socket = new SockJS("http://localhost:8080/stomp");
var client = Stomp.over(socket);
var headers = { login: "foo", passcode: "bar" };
client.connect( headers, function() {
    // do stuff
});

It would be great to be able to access the STOMP headers in the handler like this.

import org.springframework.http.server.ServerHttpRequest
import org.springframework.web.socket.WebSocketHandler
import org.springframework.web.socket.server.support.DefaultHandshakeHandler
import java.security.Principal

class ChatHandshakeHandler extends DefaultHandshakeHandler {
    @Override
    protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler,
                                      Map<String, Object> attributes) {

        // Get the STOMP login and passcode headers here. (login = foo, passcode = bar)
    }
}

Affects: 4.1.6

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions