Skip to content

marcosnils/passport-dev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Development strategy for passportjs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •