Pass authMiddleware and config to lamassu-atm-protocol
This commit is contained in:
parent
9f32dddf19
commit
3a4fe7738e
1 changed files with 7 additions and 3 deletions
10
lib/app.js
10
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);
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue