vesse / node-ldapauth-fork

Simple node.js module to authenticate against an LDAP server
Other
127 stars 79 forks source link

allow {{username}} in groupSearchFilter #62

Closed velrest closed 6 years ago

velrest commented 6 years ago

I think {{username}} should be available in the groupSearchFilter. This would require to edit this line. This would allow to filter groups by memberUid.

I would gladly open a PR if this is acceptable.

vesse commented 6 years ago

Yes of course, please open a PR. I’m very open to all PRs if they serve a purpose for more than one spesific use case :)

vesse commented 6 years ago

Thanks. I merged the PR and then looked at the code base and remembered that groupSearchFilter can be a function too, so you could have achieved this without a PR by passing

const opts = {
  ...
  groupSearchFilter: (user) =>
    'yoursearchfilter'
      .replace(/{{dn}}/g, user[opts.groupDnProperty])
      .replace(/{{username}}/g, user.uid)
};

But, it's fine having that in the default one too. I'll see what to do with another PR and then release this at some point.