Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

passport-http-header-strategy

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-http-header-strategy

HTTP Bearer set header authentication strategy for Passport

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
increased by89.17%
Maintainers
1
Weekly downloads
 
Created
Source

passport-http-header-strategy

Build Status

HTTP define header authentication strategy for Passport

Install

$ npm install passport-http-header-strategy

Usage

  • header 设置请求头(默认authorization)
  • param 设置以req.bodyreq.query参数形式请求的token名称(默认access_token)
  • passReqToCallback 是否返回
Configure Strategy
passport.use(new headerStrategy({header: 'X-APP-TOKEN', param: 'app_token', passReqToCallback: true},
  function(req, token, done) {
    User.findOne({ token: token }, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      return done(null, user, { scope: 'all' });
    });
  }
));
Authenticate Requests

Use passport.authenticate(), specifying the 'bearer' strategy, to authenticate requests. Requests containing bearer tokens do not require session support, so the session option can be set to false.

For example, as route middleware in an Express application:

app.get('/profile', 
  passport.authenticate('header', { session: false }),
  function(req, res) {
    res.json(req.user);
  });

Examples

examples - 示例

Tests

$ npm install
$ mocha

参考

参考Jared Hansonpassport-http-bearer模块

License

The MIT License

Keywords

FAQs

Package last updated on 08 Mar 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc