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

passport-http-bearer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-http-bearer

HTTP Bearer authentication strategy for Passport.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
223K
decreased by-13.96%
Maintainers
1
Weekly downloads
 
Created

What is passport-http-bearer?

The passport-http-bearer npm package is a Passport strategy for authenticating with a bearer token. This module lets you authenticate HTTP requests using bearer tokens, typically used to protect API endpoints. Bearer tokens are usually generated by an authorization server and are used to access protected resources.

What are passport-http-bearer's main functionalities?

Authenticate Requests Using Bearer Tokens

This feature allows you to authenticate HTTP requests using bearer tokens. The code sample demonstrates how to set up the BearerStrategy with Passport and protect an endpoint using this strategy.

const passport = require('passport');
const BearerStrategy = require('passport-http-bearer').Strategy;

passport.use(new BearerStrategy(
  function(token, done) {
    User.findByToken(token, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      return done(null, user);
    });
  }
));

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

Other packages similar to passport-http-bearer

Keywords

FAQs

Package last updated on 02 Aug 2013

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