mariposacoop / auther

authentication module
0 stars 1 forks source link

Integrate LDAP #1

Open gsf opened 11 years ago

gsf commented 11 years ago

So hey we got some LDAP working with a node.js library:

var ldap = require('ldapjs'); 
var client = ldap.createClient({ 
  url: 'ldaps://ldap.mariposa.coop/' 
}); 

var opts = { 
  scope: 'sub' 
}; 

// Only need to bind for setting and deleting 
//client.bind('cn=admin,dc=ldap,dc=mariposa,dc=coop', 'password', function (err) { 
//  if (err) throw err; 

client.search('ou=people,dc=ldap,dc=mariposa,dc=coop', opts, function(err, res) { 
  if (err) throw err; 

  res.on('searchEntry', function(entry) { 
    console.log('entry: ' + JSON.stringify(entry.object)); 
  }); 
  res.on('searchReference', function(referral) { 
    console.log('referral: ' + referral.uris.join()); 
  }); 
  res.on('error', function(err) { 
    console.error('error: ' + err.message); 
  }); 
  res.on('end', function(result) { 
    console.log('status: ' + result.status); 
    process.exit(); 
  }); 
}); 

//});
tmmagee commented 11 years ago

Here is some documentation I found on the "scope" option:

http://www.idevelopment.info/data/LDAP/LDAP_Resources/SEARCH_Setting_the_SCOPE_Parameter.shtml

Looks like we actually could also set it to "one" -- which would show all items immediately one node beneath the search object ( with the search object being "ou=people,dc=ldap,dc=example,dc=com").

hackartisan commented 11 years ago

We no longer need db.js, or the autheremin dependency.

We should add a file, ldap.js with a dependency on ldapjs.

note these dependencies are in server.js and routes/validate.js. do we need them in server.js?

gsf commented 11 years ago

In integrating LDAP into auther we'll also have to rethink the tests. Can we stub this out in some way or should we run a fake LDAP server?

gsf commented 11 years ago

We don't need the autheremin reference in server.js (I've removed it). We won't need that "db.on('load')" business either.