Closed
Description
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:
- Spring WebSockets should support token-based authentication [SPR-14690] #19254 Spring WebSockets should support token-based authentication