Socket
Socket
Sign inDemoInstall

passport-req

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    passport-req

opinionless authentication strategy for Passport.


Version published
Weekly downloads
3
Maintainers
1
Install size
82.9 kB
Created
Weekly downloads
 

Readme

Source

passport-req

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.

Install

$ npm install passport-req

Usage

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:

app.post('/login',
  passport.authenticate('req', { failureRedirect: '/login' }),
  function(req, res) {
    res.redirect('/');
  });

Credits

License

The MIT License

Copyright (c) 2011-2013 Jared Hanson <http://jaredhanson.net/> Copyright (c) 2014 Alexandre Perrin <https://kaworu.ch/>

Keywords

FAQs

Last updated on 22 Jan 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc