passport-dev
v1.0.1
Published
Development strategy for passportjs
Downloads
94
Readme
passport-dev
Passport strategy for development environment.
This module lets you replace your passport strategies in development for mocked responses witout having to reconfigure your application routes. By plugging into Passport, local authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Install
$ npm install passport-dev
Usage
Configure Strategy
The dev authentication strategy authenticates using a mocked data object which simulates the response obtained by the production provider.
if (process.env.NODE_ENV == 'production' ) {
passport.use(new TwitterStrategy({
consumerKey: TWITTER_CONSUMER_KEY,
consumerSecret: TWITTER_CONSUMER_SECRET,
callbackURL: "http://127.0.0.1:3000/auth/twitter/callback"
},
function(token, tokenSecret, profile, done) {
User.findOrCreate({ twitterId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
} else {
passport.use(new DevStrategy('twitter', {
user: '@marcosnils',
email: '[email protected]'
});
}
Tests
$ npm install
$ npm test