node-ldapauth-fork icon indicating copy to clipboard operation
node-ldapauth-fork copied to clipboard

Passing options to LdapAuth directly from config@^3.0.0 may fail

Open jketreno opened this issue 5 years ago • 0 comments

I'm just documenting this problem/solution here in case others encounter it.

I hadn't updated my system in a while; on updating several packages, ldapauth's authenticate started returning that it couldn't find the LDAP user, even though the user was findable using ldapsearch, or with a backup copy of node_modules I had.

After bisecting all the packages that had upgraded, I root caused the failure to a commit in npm-config which changes config objects to be immutable (commit 1fe27bf30 on npm-config)

I had been initializing ldapauth-fork via:

const config = require("config"),
  LdapAuth = require("ldapauth-fork");
const ldap = new LdapAuth(config.get("ldap"));

which previously worked fine. And seems like it should work--there are no warnings or errors printed. However, you can't authenticate anymore with the LDAP client.

The fix was to give LdapAuth a copy of the object returned from config:

const ldap = new LdapAuth(Object.assign({}, config.get("ldap")));

Cheers, James

jketreno avatar Feb 18 '20 00:02 jketreno