Merge branch 'pr/1756' into develop

Conflicts:
	src/node/handler/SocketIORouter.js
pull/1917/head
Marcel Klehr 2013-09-29 16:45:12 +02:00
commit 7b17bd58ae
4 changed files with 22 additions and 3 deletions

View File

@ -78,7 +78,10 @@
/* Require authorization by a module, or a user with is_admin set, see below. */ /* Require authorization by a module, or a user with is_admin set, see below. */
"requireAuthorization": false, "requireAuthorization": false,
/*when you use NginX or another proxy/ load-balancer set this to true*/
"trustProxy": false,
/* Users for basic authentication. is_admin = true gives access to /admin. /* Users for basic authentication. is_admin = true gives access to /admin.
If you do not uncomment this, /admin will not be available! */ If you do not uncomment this, /admin will not be available! */
/* /*

View File

@ -23,6 +23,7 @@ var ERR = require("async-stacktrace");
var log4js = require('log4js'); var log4js = require('log4js');
var messageLogger = log4js.getLogger("message"); var messageLogger = log4js.getLogger("message");
var securityManager = require("../db/SecurityManager"); var securityManager = require("../db/SecurityManager");
var settings = require('../utils/Settings');
/** /**
* Saves all components * Saves all components
@ -52,8 +53,14 @@ exports.setSocketIO = function(_socket) {
//save this socket internaly //save this socket internaly
socket = _socket; socket = _socket;
socket.sockets.on('connection', function(client) { socket.sockets.on('connection', function(client)
client.set('remoteAddress', client.handshake.address.address); {
if(settings.trustProxy && client.handshake.headers['x-forwarded-for'] !== undefined){
client.set('remoteAddress', client.handshake.headers['x-forwarded-for']);
}
else{
client.set('remoteAddress', client.handshake.address.address);
}
var clientAuthorized = false; var clientAuthorized = false;
//wrap the original send function to log the messages //wrap the original send function to log the messages

View File

@ -75,6 +75,10 @@ exports.restartServer = function () {
next(); next();
}); });
if(settings.trustProxy){
app.enable('trust proxy');
}
app.configure(function() { app.configure(function() {
hooks.callAll("expressConfigure", {"app": app}); hooks.callAll("expressConfigure", {"app": app});
}); });

View File

@ -119,6 +119,11 @@ exports.logconfig = { appenders: [{ type: "console" }]};
*/ */
exports.sessionKey = false; exports.sessionKey = false;
/*
* Trust Proxy, whether or not trust the x-forwarded-for header.
*/
exports.trustProxy = false;
/* This setting is used if you need authentication and/or /* This setting is used if you need authentication and/or
* authorization. Note: /admin always requires authentication, and * authorization. Note: /admin always requires authentication, and
* either authorization by a module, or a user with is_admin set */ * either authorization by a module, or a user with is_admin set */