Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Promise = require('bluebird');
const rfc2253 = require('rfc2253');
const LdapAuth = require('ldapauth-fork');
const Cache = require('ldapauth-fork/lib/cache');
const bcrypt = require('bcryptjs');
Promise.promisifyAll(LdapAuth.prototype);
function authenticatedUserGroups(user, groupNameAttribute) {
return [
user.cn,
// _groups or memberOf could be single els or arrays.
...user._groups ? [].concat(user._groups).map((group) => group[groupNameAttribute]) : [],
...user.memberOf ? [].concat(user.memberOf).map((groupDn) => rfc2253.parse(groupDn).get('CN')) : [],
];
}
function Auth(config, stuff) {
const self = Object.create(Auth.prototype);
self._users = {};
// config for this module
self._config = config;