New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

passport-jwt-cookie-extractor

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-jwt-cookie-extractor

Passport JWT helper to excract tokens from cookies

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Install

$ npm install passport-jwt-cookie-extractor

Usage

Configure Strategy

passport-jwt-cookie-extractor is a lightweight addition to the existing passport-jwt package that you are missing to be able to confidently work with retrieving a token from a cookie in a request.

You should pass it as jwtFromRequest param in JwtStrategy options.

var JwtStrategy = require('passport-jwt').Strategy,
    Extractor = require('passport-jwt-cookie-extractor');
var opts = {}
opts.jwtFromRequest = Extractor.fromCookie('accessToken');
opts.secretOrKey = 'secret';
opts.issuer = 'accounts.examplesoft.com';
opts.audience = 'yoursite.net';
passport.use(new JwtStrategy(opts, function(jwt_payload, done) {
    User.findOne({id: jwt_payload.sub}, function(err, user) {
        if (err) {
            return done(err, false);
        }
        if (user) {
            return done(null, user);
        } else {
            return done(null, false);
            // or you could create a new account
        }
    });
}));

Thanks

Thanks to Jared Hanson for his great Passport

Contributors

  • ptaberg

License

The MIT License

Keywords

FAQs

Package last updated on 10 Sep 2022

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