1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Add support for IIS account migration.

This commit is contained in:
Ylian Saint-Hilaire 2017-11-02 18:44:27 -07:00
parent e75adafb05
commit c0d0166184
6 changed files with 89 additions and 19 deletions

View file

@ -43,6 +43,7 @@ module.exports.CreateWebServer = function (parent, db, args, secret, certificate
obj.tls = require('tls');
obj.path = require('path');
obj.hash = require('./pass').hash;
obj.hash2 = require('./pass').hash2;
obj.constants = require('constants');
obj.bodyParser = require('body-parser');
obj.session = require('express-session');
@ -175,14 +176,24 @@ module.exports.CreateWebServer = function (parent, db, args, secret, certificate
if (user.salt == null) {
fn(new Error('invalid password'));
} else {
obj.hash(pass, user.salt, function (err, hash) {
if (err) return fn(err);
if (hash == user.hash) return fn(null, user._id);
fn(new Error('invalid password'), null, user.passhint);
});
if (user.passtype != null) {
// IIS default clear or weak password hashing (SHA-1)
obj.iishash(user.passtype, pass, user.salt, function (err, hash) {
if (err) return fn(err);
if (hash == user.hash) return fn(null, user._id);
fn(new Error('invalid password'), null, user.passhint);
});
} else {
// Default strong password hashing
obj.hash(pass, user.salt, function (err, hash) {
if (err) return fn(err);
if (hash == user.hash) return fn(null, user._id);
fn(new Error('invalid password'), null, user.passhint);
});
}
}
}
/*
obj.restrict = function (req, res, next) {
console.log('restrict', req.url);