1.0.1 • Published 9 years ago

passport-dev v1.0.1

Weekly downloads
20
License
MIT
Repository
github
Last release
9 years ago

passport-dev

Build Coverage

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: 'marcos@mydomain.com'
    });
}

Tests

$ npm install
$ npm test

Credits

License

The MIT License