Gathering detailed insights and metrics for passport
Gathering detailed insights and metrics for passport
Gathering detailed insights and metrics for passport
Gathering detailed insights and metrics for passport
Simple, unobtrusive authentication for Node.js.
npm install passport
Typescript
Module System
Min. Node Version
Node Version
NPM Version
91.7
Supply Chain
99.1
Quality
75.7
Maintenance
100
Vulnerability
100
License
JavaScript (99.83%)
Makefile (0.17%)
Total Downloads
564,986,953
Last Day
204,652
Last Week
3,439,219
Last Month
14,656,075
Last Year
144,223,487
MIT License
23,342 Stars
645 Commits
1,242 Forks
299 Watchers
16 Branches
34 Contributors
Updated on Jul 01, 2025
Minified
Minified + Gzipped
Latest Version
0.7.0
Package Id
passport@0.7.0
Unpacked Size
153.01 kB
Size
93.21 kB
File Count
21
NPM Version
8.1.2
Node Version
16.13.2
Published on
Nov 27, 2023
Cumulative downloads
Total Downloads
Last Day
11%
204,652
Compared to previous day
Last Week
-4.8%
3,439,219
Compared to previous week
Last Month
4.5%
14,656,075
Compared to previous month
Last Year
27.9%
144,223,487
Compared to previous year
3
Passport is Express-compatible authentication middleware for Node.js.
Passport's sole purpose is to authenticate requests, which it does through an extensible set of plugins known as strategies. Passport does not mount routes or assume any particular database schema, which maximizes flexibility and allows application-level decisions to be made by the developer. The API is simple: you provide Passport a request to authenticate, and Passport provides hooks for controlling what occurs when authentication succeeds or fails.
Sponsors
Your app, enterprise-ready.
Start selling to enterprise customers with just a few lines of code. Add Single Sign-On (and more) in minutes instead of months.
Drag and drop your auth
Add authentication and user management to your consumer and business apps with a few lines of code.
Auth. Built for Devs, by Devs
Add login, registration, SSO, MFA, and a bazillion other features to your app in minutes. Integrates with any codebase and installs on any server, anywhere in the world.
$ npm install passport
Passport uses the concept of strategies to authenticate requests. Strategies can range from verifying username and password credentials, delegated authentication using OAuth (for example, via Facebook or Twitter), or federated authentication using OpenID.
Before authenticating requests, the strategy (or strategies) used by an application must be configured.
1passport.use(new LocalStrategy( 2 function(username, password, done) { 3 User.findOne({ username: username }, function (err, user) { 4 if (err) { return done(err); } 5 if (!user) { return done(null, false); } 6 if (!user.verifyPassword(password)) { return done(null, false); } 7 return done(null, user); 8 }); 9 } 10));
There are 480+ strategies. Find the ones you want at: passportjs.org
Passport will maintain persistent login sessions. In order for persistent sessions to work, the authenticated user must be serialized to the session, and deserialized when subsequent requests are made.
Passport does not impose any restrictions on how your user records are stored. Instead, you provide functions to Passport which implements the necessary serialization and deserialization logic. In a typical application, this will be as simple as serializing the user ID, and finding the user by ID when deserializing.
1passport.serializeUser(function(user, done) { 2 done(null, user.id); 3}); 4 5passport.deserializeUser(function(id, done) { 6 User.findById(id, function (err, user) { 7 done(err, user); 8 }); 9});
To use Passport in an Express or
Connect-based application, configure it
with the required passport.initialize()
middleware. If your application uses
persistent login sessions (recommended, but not required), passport.session()
middleware must also be used.
1var app = express(); 2app.use(require('serve-static')(__dirname + '/../../public')); 3app.use(require('cookie-parser')()); 4app.use(require('body-parser').urlencoded({ extended: true })); 5app.use(require('express-session')({ secret: 'keyboard cat', resave: true, saveUninitialized: true })); 6app.use(passport.initialize()); 7app.use(passport.session());
Passport provides an authenticate()
function, which is used as route
middleware to authenticate requests.
1app.post('/login', 2 passport.authenticate('local', { failureRedirect: '/login' }), 3 function(req, res) { 4 res.redirect('/'); 5 });
Passport has a comprehensive set of over 480 authentication strategies covering social networking, enterprise integration, API services, and more.
There is a Strategy Search at passportjs.org
The following table lists commonly used strategies:
Strategy | Protocol | Developer |
---|---|---|
Local | HTML form | Jared Hanson |
OpenID | OpenID | Jared Hanson |
BrowserID | BrowserID | Jared Hanson |
OAuth 2.0 | Jared Hanson | |
OpenID | Jared Hanson | |
OAuth / OAuth 2.0 | Jared Hanson | |
OAuth | Jared Hanson | |
Azure Active Directory | OAuth 2.0 / OpenID / SAML | Azure |
passport-local
):
The modules page on the wiki lists other useful modules that build upon or integrate with Passport.
Copyright (c) 2011-2021 Jared Hanson <https://www.jaredhanson.me/>
4.8/10
Summary
Passport vulnerable to session regeneration when a users logs in or out
Affected Versions
< 0.6.0
Patched Versions
0.6.0
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/27 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More