From 3a4fe7738e8e9310dec782b0e55cdc1bf88e1ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Tue, 18 Mar 2014 02:24:40 +0100 Subject: [PATCH] Pass `authMiddleware` and `config` to `lamassu-atm-protocol` --- lib/app.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/app.js b/lib/app.js index 12f8cc77..c1c4e278 100755 --- a/lib/app.js +++ b/lib/app.js @@ -52,7 +52,8 @@ app.use(express.session()); config.load(function(err, conf) { if (err) { console.log(err); process.exit(1); } - atm.init(app, conf.config); + + var authMiddleware = function (req, res, next) { return next(); }; if (argv.http) { http.createServer(app).listen(port, function () { @@ -60,7 +61,7 @@ config.load(function(err, conf) { }); } else { - app.use(clientCertificateAuth({ rejectUnauthorized: false }, function(cert, done) { + authMiddleware = clientCertificateAuth({ rejectUnauthorized: false }, function(cert, done) { config.isAuthorized(cert.fingerprint, function(err, authorized) { if (err) { console.error('Client certificate authorization failed', err.message); @@ -69,7 +70,7 @@ config.load(function(err, conf) { done(authorized); }); - })); + }); var options = { key: fs.readFileSync(argv.key), @@ -84,4 +85,7 @@ config.load(function(err, conf) { console.log('Express server listening on port ' + port + ' (https)'); }); } + + atm.init(app, conf.config, config, authMiddleware); + });