You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
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
npmnpm
Version published
Weekly downloads
242K
-7.93%
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

passport

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