node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey ยป



Passport strategy for authenticating without an opinion of how you want to do it.

This module lets you authenticate in your Node.js applications. By plugging into Passport, local authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.


$ npm install passport-req


Configure Strategy

The req authentication strategy authenticates users requires a verify callback, which calls done providing a user.

passport.use(new ReqStrategy(
  function(req, done) {
    User.findOne({ username: req.query.username }, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      if (!user.verifyPassword(req.query.password)) { return done(null, false); }
      return done(null, user);

Authenticate Requests

Use passport.authenticate(), specifying the 'req' strategy, to authenticate requests.

For example, as route middleware in an Express application:'/login',
  passport.authenticate('req', { failureRedirect: '/login' }),
  function(req, res) {



The MIT License

Copyright (c) 2011-2013 Jared Hanson <> Copyright (c) 2014 Alexandre Perrin <>