My project use Spring Security + Spring MVC and deals with websocket (over stomp+sockjs).
When I test the sockjs fallback the XHR request return 403.
If I turn off csrf on the security context it's OK.
If I override the sockjs AbstractXHRObject constructor like this : it's ok :
function AbstractXHRObject(method, url, payload, opts) {
debug(method, url);
var self = this;
EventEmitter.call(this);
// HACK : add csrf headers
opts["headers"][csrfHeader] = csrfToken;
setTimeout(function () {
self._start(method, url, payload, opts);
}, 0);
}
Off course I have to check if opts is not null...
My question is : What is the way to add headers on the XHR fallback object of SockJS ?
Thanks