Skip to content

Commit

Permalink
added socketio authorization (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoR committed Feb 18, 2013
1 parent e346d8b commit 7981a2b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/Webserver/Webserver.js
Expand Up @@ -17,8 +17,8 @@ var Collector = require('../Collector');


function WebServer(webPort) {
if (!(this instanceof WebServer))
return new WebServer(webPort);
if (!(this instanceof WebServer))
return new WebServer(webPort);

var app = express();
var server = http.createServer(app);
Expand All @@ -27,6 +27,16 @@ function WebServer(webPort) {
// Socket.io (Express 3 method of integration)
var io = sio.listen(server);
io.set('log level', 1);
io.configure(function () {
// use global authorization and reject all cross-domain connection attempts
io.set('authorization', function (handshakeData, callback) {
if (handshakeData.xdomain) {
callback('Cross-domain connections are not allowed');
} else {
callback(null, true);
}
});
});

// io.sockets.on('connection', function(socket) {
// // console.log('GOT SOCKET IO CONNECTION');
Expand Down

0 comments on commit 7981a2b

Please sign in to comment.