ldapauth-fork
Advanced tools
Comparing version 2.5.3 to 2.5.4
# node-ldapauth-fork Changelog | ||
## 2.5.4 | ||
- [pull request #42] Update ldapjs to 1.0.1 (and use ~ in package.json for it) | ||
## 2.5.3 | ||
@@ -4,0 +8,0 @@ |
@@ -93,10 +93,2 @@ /** | ||
* for available options | ||
* maxConnections {Integer} | ||
* Whether or not to enable connection pooling, and if so, how many to | ||
* maintain. | ||
* checkInterval {Integer} | ||
* How often to schedule health checks for the connection pool. | ||
* maxIdleTime {Integer} | ||
* How long a client can be idle before health-checking the connection | ||
* (subject to the checkInterval frequency) | ||
* includeRaw {boolean} | ||
@@ -132,7 +124,4 @@ * Optional, default false. Set to true to add property '_raw' | ||
tlsOptions: opts.tlsOptions, | ||
maxConnections: opts.maxConnections, | ||
bindDn: getOption(opts, ['bindDn', 'adminDn']), | ||
bindCredentials: getOption(opts, ['bindCredentials', 'Credentials', 'adminPassword']), | ||
checkInterval: opts.checkInterval, | ||
maxIdleTime: opts.maxIdleTime, | ||
reconnect: opts.reconnect | ||
@@ -323,3 +312,3 @@ }; | ||
var self = this; | ||
if (typeof password === 'undefined' || password === null || password === '') { | ||
@@ -326,0 +315,0 @@ return callback('no password given'); |
{ | ||
"name": "ldapauth-fork", | ||
"version": "2.5.3", | ||
"version": "2.5.4", | ||
"main": "./lib/ldapauth.js", | ||
@@ -23,5 +23,5 @@ "description": "Authenticate against an LDAP server", | ||
"bcryptjs": "2.3.0", | ||
"ldapjs": "1.0.0", | ||
"ldapjs": "~1.0.1", | ||
"lru-cache": "3.2.0" | ||
} | ||
} |
@@ -36,3 +36,3 @@ Fork of [node-ldapauth](https://github.com/trentm/node-ldapauth) - A simple node.js lib to authenticate against an LDAP server. | ||
[Use the source Luke](https://github.com/vesse/node-ldapauth-fork/blob/master/lib/ldapauth.js#L35-L106) | ||
[Use the source Luke](https://github.com/vesse/node-ldapauth-fork/blob/master/lib/ldapauth.js#L35-L99) | ||
@@ -43,34 +43,34 @@ | ||
```javascript | ||
var connect = require('connect'); | ||
var basicAuth = require('basic-auth'); | ||
var LdapAuth = require('ldapauth-fork'); | ||
// Config from a .json or .ini file or whatever. | ||
var config = { | ||
ldap: { | ||
url: "ldaps://ldap.example.com:636", | ||
bindDn: "uid=myadminusername,ou=users,o=example.com", | ||
bindCredentials: "mypassword", | ||
searchBase: "ou=users,o=example.com", | ||
searchFilter: "(uid={{username}})" | ||
} | ||
}; | ||
var ldap = new LdapAuth({ | ||
url: config.ldap.url, | ||
bindDn: config.ldap.bindDn, | ||
bindCredentials: config.ldap.bindCredentials, | ||
searchBase: config.ldap.searchBase, | ||
searchFilter: config.ldap.searchFilter, | ||
//log4js: require('log4js'), | ||
cache: true | ||
url: "ldaps://ldap.example.com:636", | ||
bindDn: "uid=myadminusername,ou=users,o=example.com", | ||
bindCredentials: "mypassword", | ||
searchBase: "ou=users,o=example.com", | ||
searchFilter: "(uid={{username}})" | ||
}); | ||
var basicAuthMiddleware = connect.basicAuth(function (username, password, callback) { | ||
ldap.authenticate(username, password, function (err, user) { | ||
var rejectBasicAuth = function(res) { | ||
res.statusCode = 401; | ||
res.setHeader('WWW-Authenticate', 'Basic realm="Example"'); | ||
res.end('Access denied'); | ||
} | ||
var basicAuthMiddleware = function(req, res, next) { | ||
var credentials = basicAuth(req); | ||
if (!credentials) { | ||
return rejectBasicAuth(res); | ||
} | ||
ldap.authenticate(credentials.name, credentials.pass, function(err, user) { | ||
if (err) { | ||
console.log("LDAP auth error: %s", err); | ||
return rejectBasicAuth(res); | ||
} | ||
callback(err, user) | ||
req.user = user; | ||
next(); | ||
}); | ||
}); | ||
}; | ||
``` |
20
test.js
@@ -22,4 +22,3 @@ var LdapAuth = require('./lib/ldapauth'); | ||
"searchBase": "dc=example,dc=com", | ||
"searchFilter": "(uid={{username}})", | ||
"cache": true | ||
"searchFilter": "(uid={{username}})" | ||
} | ||
@@ -31,13 +30,14 @@ | ||
if (err) { | ||
console.warn(err); | ||
console.warn(err, user); | ||
} else { | ||
console.dir(user, {depth: null}); | ||
} | ||
a.authenticate('riemann', 'password', function(err, user) { | ||
console.log('second'); | ||
a.close(function(err, res) { | ||
console.log(err); | ||
console.log(res); | ||
}); | ||
}); | ||
a.close(); | ||
// a.authenticate('riemann', 'password', function(err, user) { | ||
// console.log('second'); | ||
// a.close(function(err, res) { | ||
// console.log(err); | ||
// console.dir(res, {depth: null}); | ||
// }); | ||
// }); | ||
}); |
70771
1010
+ Addedassert-plus@1.0.0(transitive)
+ Addedbackoff@2.5.0(transitive)
+ Addedbunyan@1.8.15(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddtrace-provider@0.8.8(transitive)
+ Addedldapjs@1.0.2(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedvasync@1.6.4(transitive)
+ Addedverror@1.10.1(transitive)
- Removedbackoff@2.4.1(transitive)
- Removedbunyan@1.5.1(transitive)
- Removeddashdash@1.10.1(transitive)
- Removeddtrace-provider@0.6.0(transitive)
- Removedldapjs@1.0.0(transitive)
- Removedonce@1.3.2(transitive)
- Removedvasync@1.6.3(transitive)
Updatedldapjs@~1.0.1