parent
53a51b354c
commit
efeb7a6987
12 changed files with 103 additions and 45 deletions
@ -1 +1 @@ |
|||||||
/usr/share/automake-1.14/COPYING |
/usr/share/automake-1.15/COPYING |
@ -1 +1 @@ |
|||||||
/usr/share/automake-1.14/INSTALL |
/usr/share/automake-1.15/INSTALL |
After Width: | Height: | Size: 237 KiB |
After Width: | Height: | Size: 117 KiB |
After Width: | Height: | Size: 193 KiB |
@ -1,51 +1,78 @@ |
|||||||
module.exports = function(config) { |
module.exports = function(config) { |
||||||
|
|
||||||
authentication = function (username, password, success, fail) { |
var authentication; |
||||||
|
|
||||||
if (config) { |
if (config) { |
||||||
|
|
||||||
|
authentication = function (username, password, success, fail) { |
||||||
|
|
||||||
|
console.log("...try: ", username); |
||||||
const crypto = require('crypto'); |
const crypto = require('crypto'); |
||||||
if (config.passwords && config.passwords[username]) { |
if (config.passwords && config.passwords[username]) { |
||||||
|
console.log("...check hash"); |
||||||
if (crypto.getHashes().indexOf(config.passwords[username][0])>=0) { |
if (crypto.getHashes().indexOf(config.passwords[username][0])>=0) { |
||||||
if (crypto.createHash(config.passwords[username][0]).update(password, 'utf8').digest('hex') === config.passwords[username][1]) { |
if (crypto.createHash(config.passwords[username][0]).update(password, 'utf8').digest('hex') === config.passwords[username][1]) { |
||||||
success(); |
success(username); |
||||||
return; |
return; |
||||||
} else { |
} else { |
||||||
fail(); |
fail(username); |
||||||
return; |
return; |
||||||
} |
} |
||||||
} else { |
} else { |
||||||
console.log("**** HASH NOT FOUND ****"); |
console.log("**** HASH NOT FOUND ****"); |
||||||
console.log(config.passwords[username][0]); |
console.log(config.passwords[username][0]); |
||||||
console.log(crypto.getHashes()); |
console.log(crypto.getHashes()); |
||||||
fail(); |
fail(username); |
||||||
return; |
return; |
||||||
} |
} |
||||||
} |
} |
||||||
if (config.ldap) try { |
if (config.ldap) try { |
||||||
|
console.log("...check ldap"); |
||||||
var LdapAuth = require('ldapauth'); |
var LdapAuth = require('ldapauth'); |
||||||
var auth = new LdapAuth(config.ldap); |
var auth = new LdapAuth(config.ldap); |
||||||
|
auth.once('connect', function () { |
||||||
|
try { |
||||||
auth.authenticate(username, password, function(err, usr) { |
auth.authenticate(username, password, function(err, usr) { |
||||||
auth.close(function(err) {}) |
auth.close(function(err) {}) |
||||||
if (err) { |
if (err) { |
||||||
console.log("**** ERROR: LDAP Authentication failed:", err); |
console.log("**** ERROR: LDAP Authentication failed:", err); |
||||||
fail(); |
fail(username); |
||||||
return; |
return; |
||||||
} |
} |
||||||
console.log("**** SUCCESS: LDAP Authentication:"); |
console.log("**** SUCCESS: LDAP Authentication:"); |
||||||
success(); |
success(username); |
||||||
return; |
return; |
||||||
}); |
}); |
||||||
|
} catch (e) { |
||||||
|
console.log("**** Error: LDAP failed: ", e, e.stack); |
||||||
|
fail(username); |
||||||
|
} |
||||||
return; // need to block here!
|
return; // need to block here!
|
||||||
|
}); |
||||||
} catch (e) { |
} catch (e) { |
||||||
console.log("**** Error: LDAP failed: ", e, e.stack); |
console.log("**** Error: LDAP failed: ", e, e.stack); |
||||||
fail(); |
fail(username); |
||||||
return; |
return; |
||||||
} |
} |
||||||
} |
if (config.unrestricted) |
||||||
fail(); |
success(username); |
||||||
|
else |
||||||
|
fail(username); |
||||||
return; |
return; |
||||||
} |
} |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
authentication = function (username, password, success, fail) { |
||||||
|
console.log('**** Error: no access configuraion. To allow any user, add:') |
||||||
|
console.log(' "restrict": {'); |
||||||
|
console.log(' "unrestricted": true'); |
||||||
|
console.log(' }'); |
||||||
|
fail(username); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
return authentication; |
return authentication; |
||||||
|
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue