passport-ldapauth = function (options, verify) { // We now accept function as options as well so we cannot assume anymore // that a call with a function parameter only would have skipped options // and just provided a verify callback if (!options) { throw new Error('LDAP authentication strategy requires options'); } this.options = null; this.getOptions = null; if (typeof options === 'object') { this.options = setDefaults(options); } else if (typeof options === 'function') { this.getOptions = options; } passport.Strategy.call(this); this.name = 'ldapauth'; this.verify = verify; }
n/a
Strategy = function (options, verify) { // We now accept function as options as well so we cannot assume anymore // that a call with a function parameter only would have skipped options // and just provided a verify callback if (!options) { throw new Error('LDAP authentication strategy requires options'); } this.options = null; this.getOptions = null; if (typeof options === 'object') { this.options = setDefaults(options); } else if (typeof options === 'function') { this.getOptions = options; } passport.Strategy.call(this); this.name = 'ldapauth'; this.verify = verify; }
n/a
function Strategy() { }
n/a
Strategy = function (options, verify) { // We now accept function as options as well so we cannot assume anymore // that a call with a function parameter only would have skipped options // and just provided a verify callback if (!options) { throw new Error('LDAP authentication strategy requires options'); } this.options = null; this.getOptions = null; if (typeof options === 'object') { this.options = setDefaults(options); } else if (typeof options === 'function') { this.getOptions = options; } passport.Strategy.call(this); this.name = 'ldapauth'; this.verify = verify; }
n/a
function Strategy() { }
n/a
authenticate = function (req, options) { if ((typeof this.options === 'object') && (!this.getOptions)) { return handleAuthentication.call(this, req, options); } var callback = function(err, configuration) { if (err) return this.fail(err); this.options = setDefaults(configuration); handleAuthentication.call(this, req, options); }; // Added functionality: getOptions can accept now up to 2 parameters if (this.getOptions.length ===1) { // Accepts 1 parameter, backwards compatibility this.getOptions(callback.bind(this)); } else { // Accepts 2 parameters, pass request as well this.getOptions(req, callback.bind(this)); } }
...
}
));
Note: you can pass a function instead of an object as `options`, see the [example below](#options-as-function)
### Authenticate requests
Use `passport.authenticate()`, specifying the `'ldapauth'` strategy, to authenticate
requests.
#### `authenticate()` options
In addition to [default authentication options](http://passportjs.org/guide/authenticate/) the following flash message options are
available for `passport.authenticate()`:
* `badRequestMessage`: missing username/password (default: 'Missing credentials')
* `invalidCredentials`: `InvalidCredentialsError`, `NoSuchObjectError`, and `/no such user/i` LDAP errors (default: 'Invalid
username/password')
...
function Strategy() { }
n/a
function Strategy() { }
n/a
authenticate = function (req, options) { throw new Error('Strategy#authenticate must be overridden by subclass'); }
...
}
));
Note: you can pass a function instead of an object as `options`, see the [example below](#options-as-function)
### Authenticate requests
Use `passport.authenticate()`, specifying the `'ldapauth'` strategy, to authenticate
requests.
#### `authenticate()` options
In addition to [default authentication options](http://passportjs.org/guide/authenticate/) the following flash message options are
available for `passport.authenticate()`:
* `badRequestMessage`: missing username/password (default: 'Missing credentials')
* `invalidCredentials`: `InvalidCredentialsError`, `NoSuchObjectError`, and `/no such user/i` LDAP errors (default: 'Invalid
username/password')
...