New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

passport-ldapauth

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-ldapauth - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

11

lib/passport-ldapauth/strategy.js

@@ -177,4 +177,3 @@ "use strict";

}
this.getOptions(function(err, configuration) {
var callback = function(err, configuration) {
if (err) return this.fail(err);

@@ -184,5 +183,11 @@

handleAuthentication.call(this, req, options);
}.bind(this));
};
// 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));
}
};
module.exports = Strategy;

@@ -8,3 +8,4 @@ {

"Michael Bailly <mbailly@linagora.com>",
"Jason Gelinas <jason.gelinas@citi.com>"
"Jason Gelinas <jason.gelinas@citi.com>",
"arumi <arumi@wge7033.secheron.net>"
],

@@ -17,3 +18,3 @@ "keywords": [

],
"version": "0.2.5",
"version": "0.2.6",
"license": {

@@ -20,0 +21,0 @@ "type": "MIT",

@@ -125,6 +125,6 @@ # passport-ldapauth

Instead of providing a static configuration object, you can pass a function as `options` that will take care of fetching the configuration. It will be called with a callback function having the standard `(err, result)` signature. Notice that the provided function will be called on every authenticate request.
Instead of providing a static configuration object, you can pass a function as `options` that will take care of fetching the configuration. It will be called with the and a callback function having the standard `(err, result)` signature. Notice that the provided function will be called on every authenticate request.
```javascript
var getLDAPConfiguration = function(callback) {
var getLDAPConfiguration = function(req, callback) {
// Fetching things from database or whatever

@@ -131,0 +131,0 @@ process.nextTick(function() {

@@ -231,2 +231,57 @@ var should = require('chai').Should(),

});
describe("with options as function returning dynamic sets", function() {
var OPTS = JSON.parse(JSON.stringify(BASE_OPTS));
OPTS.usernameField = 'first_uname';
OPTS.passwordField = 'first_pwd';
var OPTS2 = JSON.parse(JSON.stringify(BASE_OPTS));
OPTS2.usernameField = 'second_uname';
OPTS2.passwordField = 'second_pwd';
var opts = function(req, cb) {
process.nextTick(function() {
if (req.body.set == 'first') {
cb(null, OPTS);
} else {
cb(null, OPTS2);
}
});
};
before(start_servers(opts, BASE_TEST_OPTS));
after(stop_servers);
it("should use the first set options returned from the function", function(cb) {
request(expressapp)
.post('/login')
.send({first_uname: 'valid', first_pwd: 'valid', set: 'first'})
.expect(200)
.end(cb);
});
it("should not allow first set login if using wrong fields", function(cb) {
request(expressapp)
.post('/login')
.send({second_uname: 'valid', second_pwd: 'valid', set: 'first'})
.expect(400)
.end(cb);
});
it("should use the second set options returned from the function", function(cb) {
request(expressapp)
.post('/login')
.send({second_uname: 'valid', second_pwd: 'valid', set: 'second'})
.expect(200)
.end(cb);
});
it("should not allow second set login if using wrong fields", function(cb) {
request(expressapp)
.post('/login')
.send({first_uname: 'valid', first_pwd: 'valid', set: 'second'})
.expect(400)
.end(cb);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc