Create ldap client per login attempt
This seems stupid to not just bind then unbind, but it seems that the joyent ldap library does not support this, as a second call to bind, even after an unbind, just hangs.
This commit is contained in:
parent
1095d80a34
commit
4ba6fde7c8
6
index.js
6
index.js
|
@ -16,7 +16,6 @@ module.exports = function(plugin) {
|
|||
}
|
||||
});
|
||||
|
||||
var client = ldap.createClient(plugin.conf.options)
|
||||
|
||||
function requestAuth(res) {
|
||||
res.set('WWW-Authenticate', 'Basic realm="Auth"');
|
||||
|
@ -41,6 +40,9 @@ module.exports = function(plugin) {
|
|||
return;
|
||||
}
|
||||
|
||||
// It seems stupid to create a client each time, but joyent's ldapjs cannot bind then unbind to the same client multiple times...
|
||||
var client = ldap.createClient(plugin.conf.options)
|
||||
|
||||
client.bind(plugin.conf.bind.dn.replace('%u', login), plugin.conf.bind.password.replace('%p', password), function(err) {
|
||||
if (err) {
|
||||
console.log('E: ldap.bind: ', err)
|
||||
|
@ -51,8 +53,8 @@ module.exports = function(plugin) {
|
|||
if (err) {
|
||||
console.log('E: ldap.unbind: ', err)
|
||||
}
|
||||
next();
|
||||
})
|
||||
next();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user