fixed ATM authorizing
This commit is contained in:
parent
f8c507bb1c
commit
c6db15b154
1 changed files with 9 additions and 9 deletions
18
lib/app.js
18
lib/app.js
|
|
@ -28,7 +28,6 @@ var argv = require('optimist').argv;
|
|||
var LamassuConfig = require('lamassu-config');
|
||||
var atm = require('lamassu-atm-protocol');
|
||||
var format = require('util').format;
|
||||
var clientCertificateAuth = require('client-certificate-auth');
|
||||
|
||||
var conString, dbConfig, config;
|
||||
|
||||
|
|
@ -61,16 +60,17 @@ config.load(function(err, conf) {
|
|||
});
|
||||
}
|
||||
else {
|
||||
authMiddleware = clientCertificateAuth({ rejectUnauthorized: false }, function(cert, done) {
|
||||
config.isAuthorized(cert.fingerprint, function(err, authorized) {
|
||||
if (err) {
|
||||
console.error('Client certificate authorization failed', err.message);
|
||||
return done(false);
|
||||
}
|
||||
authMiddleware = function(req, res, next) {
|
||||
var fingerprint = req.connection.getPeerCertificate().fingerprint;
|
||||
var e = new Error('Unauthorized');
|
||||
e.status = 401;
|
||||
|
||||
done(authorized);
|
||||
config.isAuthorized(fingerprint, function (err, authorized) {
|
||||
if (err) { return next(e); }
|
||||
if (!authorized) { return next(e); }
|
||||
next();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var options = {
|
||||
key: fs.readFileSync(argv.key),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue