ldap authentication works

single-host
Marc Wäckerlin 8 years ago
parent 53a51b354c
commit efeb7a6987
  1. 2
      COPYING
  2. 36
      ChangeLog
  3. 2
      INSTALL
  4. BIN
      doc/screenshot10.png
  5. BIN
      doc/screenshot11.png
  6. BIN
      doc/screenshot12.png
  7. 63
      nodejs/authentication/index.js
  8. 29
      nodejs/etc/servicedock.json
  9. 0
      nodejs/etc/systemd/system/servicedock.service
  10. 3
      nodejs/package.json.in
  11. 4
      nodejs/servicedock.js
  12. 9
      nodejs/sockets/index.js

@ -1 +1 @@
/usr/share/automake-1.14/COPYING /usr/share/automake-1.15/COPYING

@ -1,3 +1,39 @@
2016-09-20 15:00 marc
* autogen.sh, ax_cxx_compile_stdcxx_11.m4,
ax_init_standard_project.m4, bootstrap.sh, build-in-docker.sh,
doc/doxyfile.in, doc/footer.html.in, doc/header.html.in,
doc/plantuml.jar, doc/style.css, makefile_test.inc.am,
nodejs/authentication/index.js, nodejs/etc/servicedock.json,
nodejs/package.json.in, nodejs/public/javascripts/servicedock.js,
nodejs/public/stylesheets/servicedock.css, nodejs/servicedock.js,
nodejs/sockets/index.js, nodejs/views/index.ejs,
resolve-debbuilddeps.sh, resolve-rpmbuilddeps.sh, sql-to-dot.sed:
login is possible
2016-07-29 19:25 marc
* nodejs/authentication, nodejs/authentication/index.js,
nodejs/etc/servicedock.json, nodejs/package.json.in,
nodejs/public/javascripts/servicedock.js, nodejs/routes/index.js,
nodejs/servicedock.js, nodejs/sockets/index.js,
nodejs/views/index.ejs, scripts, scripts/docker-backup.sh: in the
middle of the work for authentication
2016-04-03 16:19 marc
* ChangeLog: after svn-server restore
2016-03-02 15:25 marc
* ax_init_standard_project.m4, bootstrap.sh, build-in-docker.sh,
debian/control.in, debian/servicedock.postinst,
mac-create-app-bundle.sh, nodejs/etc/default,
nodejs/etc/default/servicedock, nodejs/etc/init,
nodejs/etc/init/servicedock.conf, nodejs/etc/servicedock.json,
nodejs/makefile.am, nodejs/servicedock.js: proper packaging and
upstart scripts for ubuntu
2016-02-19 15:27 marc 2016-02-19 15:27 marc
* ChangeLog, nodejs/sockets/index.js: little fix: fail outside of * ChangeLog, nodejs/sockets/index.js: little fix: fail outside of

@ -1 +1 @@
/usr/share/automake-1.14/INSTALL /usr/share/automake-1.15/INSTALL

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

@ -1,49 +1,76 @@
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.authenticate(username, password, function(err, usr) { auth.once('connect', function () {
auth.close(function(err) {}) try {
if (err) { auth.authenticate(username, password, function(err, usr) {
console.log("**** ERROR: LDAP Authentication failed:", err); auth.close(function(err) {})
fail(); if (err) {
return; console.log("**** ERROR: LDAP Authentication failed:", err);
fail(username);
return;
}
console.log("**** SUCCESS: LDAP Authentication:");
success(username);
return;
});
} catch (e) {
console.log("**** Error: LDAP failed: ", e, e.stack);
fail(username);
} }
console.log("**** SUCCESS: LDAP Authentication:"); return; // need to block here!
success();
return;
}); });
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)
success(username);
else
fail(username);
return;
} }
fail();
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;

@ -1,20 +1,15 @@
{ {
"port": 8888, "port": 8888,
"restrict": { "restrict": {
"passwords": { "passwords": {
"marc": ["sha256", "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"], "foo": ["sha256", "fcde2b2edxx56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9"]
"foo": ["sha256", "fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9"] },
}, "ldap": {
"ldap": { "url": "ldap://dev.marc.waeckerlin.org",
"tlsOptions": { "adminDn": "cn=tmp,ou=system,ou=people,dc=dev,dc=marc,dc=waeckerlin,dc=org",
"requestCert": false, "adminPassword": "secret",
"rejectUnauthorized": false "searchBase": "ou=person,ou=people,dc=dev,dc=marc,dc=waeckerlin,dc=org",
}, "searchFilter": "(uid={{username}})"
"url": "ldap://dev.marc.waeckerlin.org",
"adminDn": "cn=tmp,ou=system,ou=people,dc=dev,dc=marc,dc=waeckerlin,dc=org",
"adminPassword": "dGg7benUnZ9z",
"searchBase": "ou=person,ou=people,dc=dev,dc=marc,dc=waeckerlin,dc=org",
"searchFilter": "(uid={{username}})"
}
} }
}
} }

@ -9,7 +9,8 @@
"socket.io": "~1.4.4", "socket.io": "~1.4.4",
"pty.js": "~0.3.0", "pty.js": "~0.3.0",
"async": "~1.5.2", "async": "~1.5.2",
"socketio-auth": "0.0.5" "socketio-auth": "0.0.5",
"ldapauth": "git+https://github.com/DimensionSoftware/node-ldapauth.git"
}, },
"description": "@DESCRIPTION@", "description": "@DESCRIPTION@",
"main": "@PACKAGE_NAME@.js", "main": "@PACKAGE_NAME@.js",

@ -19,8 +19,8 @@ try {
var package = require(__dirname+'/package.json'); var package = require(__dirname+'/package.json');
var config = require(package.path.config); var config = require(package.path.config);
var docker = require(__dirname+'/docker')(app); var docker = require(__dirname+'/docker')(app);
//var authentication = require(__dirname+'/authentication')(config.restrict); var authentication = require(__dirname+'/authentication')(config.restrict);
var sockets = require(__dirname+'/sockets')(io); var sockets = require(__dirname+'/sockets')(io, authentication);
// Configuration // Configuration
process.argv.forEach(function(val, index) { process.argv.forEach(function(val, index) {

@ -1,4 +1,4 @@
module.exports = function(io) { module.exports = function(io, authentication) {
var pty = require('pty.js'); var pty = require('pty.js');
var proc = require('child_process'); var proc = require('child_process');
@ -287,10 +287,9 @@ module.exports = function(io) {
//get credentials sent by the client //get credentials sent by the client
var username = data.username; var username = data.username;
var password = data.password; var password = data.password;
if (username=="hello") authentication(data.username, data.password,
return callback(null, "world" == password); function() {console.log("####LOGIN-SUCESS####");callback(null, true)},
else function() {console.log("####LOGIN-FAIL####");callback(new Error("wrong credentials"))});
return callback(new Error("wrong credentials"));
}, },
postAuthenticate: connection, postAuthenticate: connection,
timeout: "none" timeout: "none"

Loading…
Cancel
Save