Node.js authentication mechanism with LDAP

I want to implement an application login mechanism since the users are sitting on the LDAP server and not the local database.

Iv'e thought about implementing his passport.js, but I'm trying to figure out the other part of the solution - I can choose passport-ldap , or I can try ... implement the solution with a "local" strategy:

passport.use(new LocalStrategy(
  function(username, password, done) {
    User.findOne({ username: username }, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      if (!user.verifyPassword(password)) { return done(null, false); }
      return done(null, user);
    });
  }
));

      

Where can function(user, password, done)

ldapjs be injected .

I'm not sure which option would work best. I think the second might give me more control over the login process, but using an LDAP strategy might make a little more sense.

Any suggestions?

+3


source to share





All Articles