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

errorhandler called twice in strategy.js if LDAP server unreachable #106

Open
2 tasks done
julianlam opened this issue Mar 11, 2021 · 1 comment
Open
2 tasks done

Comments

@julianlam
Copy link

  • I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions, such as how to use the library, there).
  • I believe this is an issue in this library and not in the underlying libraries ldapjs or ldapauth-fork. (This library is a passport strategy and does not implement the LDAP communication)

Problem Description

I am building an ldap authentication flow for my app and I am encountering a condition where the errorHandler is called twice, leading to the passport.authenticate callback to be called twice.

I believe this is caused by line 274 ldap.once('error', errorHandler);, which proceeds to call ldap.authenticate without ensuring the server connection is valid. Sometimes the errorHandler after // Other errors are (most likely) real errors is called first, sometimes it is called second, so it is a race condition, but they shouldn't ever be called twice anyhow.

Steps to Reproduce

Set up LdapStrategy with url pointing to an unreachable server. In my case, it is a server inside an internal network that I do not have access to. The specific error is ENOTFOUND, so I think putting in any invalid url should work.

passport.authenticate(strategy, async (err, userData, info) => {
  console.log(err);
}

Error will be output twice.

@safonoi
Copy link

safonoi commented Jun 21, 2023

The problem is actual. There is a solution?

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

2 participants