Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error on bad credentials #87

Open
victornikitin opened this issue Apr 19, 2019 · 6 comments
Open

No error on bad credentials #87

victornikitin opened this issue Apr 19, 2019 · 6 comments

Comments

@victornikitin
Copy link

How to catch that bindDN or bindCredentials are incorrect?

I pass authenticate to express via router:

router.use(
    passport.authenticate('ldapauth'),
    function(err, req, res, next) {
      // this code is not called when server credentials are wrong
      // only 403 forbidden is returned to user
      console.log(err);
      next();
    }
  );

Even if I create strategy with handleErrorsAsFailures option, failureErrorCallback does not trigger too.

How to catch this situation?
Or what I'm doing wrong?

@vesse
Copy link
Owner

vesse commented Apr 24, 2019

You are apparently trying to use custom callbacks, see that on how the middleware needs to be called then.

@victornikitin
Copy link
Author

You are right. I've changed code to this:

passport.use("ldapauth", LDAPStrategy({...}, authenticateLdap) );
function authenticateLdap(profile, done) {
    if (!profile) {
      done(null, false, { message: options.incorrectPasswordError });
      return;
    }
    ...
}
...
router.use(function(req, res, next) {
    passport.authenticate('ldapauth', async function(err, user, message) {
      if (!user) {
       // user password is wrong or binddn credentials is wrong?
      }
      req.logIn(user, function(err) {
       next();
      });
    })(req, res, next);
  });

But how to check if it user password is incorrect or bindDN credentials are incorrect?

@vesse
Copy link
Owner

vesse commented Apr 25, 2019

The strategy does not provide such info as this is more of a configuration error. It is sort of expected that admin credentials are provided correctly. You can pass a Bunyan logger instance to the underlying ldapauth-fork library and see the trace for bind errors, or try eg. with command line tool ldapsearch to see if your admin credentials are correct.

@clarkey
Copy link

clarkey commented Mar 6, 2020

@victornikitin Hi. I came across this issue just now. Did you come up with anything?

@victornikitin
Copy link
Author

victornikitin commented Mar 16, 2020 via email

@MarkusRissmann
Copy link

MarkusRissmann commented Jul 8, 2020

I'm having the same issue. No matter what I am getting "Unauthorized". I wrote a quick c# .net app using all the same settings and it works (queries). I know my code works because I've used it against another ldap server. Kind of hard to ask IT to fix something when you don't know what is wrong.

Using wireshark to diagnose I see this using nodejs:

image

But using .Net App I see much more activity:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants