Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 1.77 KB

README.md

File metadata and controls

64 lines (48 loc) · 1.77 KB

passport-dev

Build Coverage Status

Passport strategy for development environment.

This module lets you replace your passport strategies in development for mocked responses without 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 {
    var DevStrategy = require('passport-dev');
    passport.use(new DevStrategy('twitter', {
        user: '@marcosnils',
        email: '[email protected]'
    }));
}

Tests

$ npm install
$ npm test

Credits

License

The MIT License