passport

Simple, unobtrusive authentication middleware for Node.js with 480+ pluggable strategies.

Library
npm
v0.7.0
23,528stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
43/100Fair
Development Activity0
Maintenance0
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture85
Code Quality82
Innovation88
Learning Curve80

Passport is Express-compatible authentication middleware for Node.js whose sole purpose is to authenticate requests. It does this through an extensible set of plugins known as strategies, ranging from verifying username and password credentials to delegated authentication via OAuth, OpenID, and SAML.

Passport does not mount routes or assume any particular database schema, which maximizes flexibility and lets application-level decisions stay with the developer. You provide Passport a request to authenticate, and it provides hooks for controlling what happens when authentication succeeds or fails.

What You Get

  • A single authenticate() route middleware that plugs into any Express or Connect app
  • Access to an ecosystem of 480+ community strategies covering local, OAuth, OpenID Connect, and SAML
  • Persistent login sessions via configurable serialize/deserialize hooks
  • A framework-agnostic core that imposes no routing or database schema on your app

Common Use Cases

  • Adding username/password login to an Express application with passport-local
  • Enabling social sign-in through Google, Facebook, or Twitter OAuth strategies
  • Integrating enterprise SSO via SAML or OpenID Connect strategies
  • Protecting API routes by requiring an authenticated session before access

Under The Hood

Architecture

Passport centers on the Authenticator class in lib/authenticator.js, exported as a default singleton from lib/index.js. On construction it adapts itself to Connect/Express via lib/framework/connect.js, registers a default SessionStrategy (lib/strategies/session.js), and wires up a SessionManager (lib/sessionmanager.js). Strategies are registered in a _strategies map through use(), and authenticate(name, options) in lib/middleware/authenticate.js returns Connect-style middleware that looks up the named strategy, instruments a per-request set of callbacks (success/fail/redirect/error), and drives the strategy’s authenticate() method. The initialize() middleware (lib/middleware/initialize.js) augments the request with helpers exposed via lib/http/request.js, and serialize/deserialize chains persist the authenticated user across the session.

Tech Stack

Pure JavaScript (99.8% of the codebase), targeting Node.js >= 0.4.0. Runtime dependencies are intentionally minimal: passport-strategy (the abstract Strategy base class shared by all strategies), pause (to buffer request events during async deserialization), and utils-merge. Tests run on Mocha with Chai and proxyquire. No build step or transpilation — the package’s main points directly at lib/.

Code Quality

The library ships a thorough Mocha test suite under test/ covering the authenticator, framework adapter, middleware, HTTP request extensions, and session strategy. Source files are small, single-responsibility modules with extensive JSDoc annotations on the public API. Error handling is explicit — use() throws when a strategy has no name, and a dedicated AuthenticationError class lives in lib/errors/. The codebase is stable and mature rather than actively evolving.

API Design

The public surface is deliberately tiny and ergonomic: passport.use() to register strategies, passport.serializeUser()/deserializeUser() for session persistence, and passport.authenticate() as drop-in route middleware. This small, consistent API is a large part of why Passport became the de-facto Node.js auth standard — getting started requires only a few lines, and every strategy follows the same registration and invocation contract.

Used by 30 apps in this directory

TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,010

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
JavaScript
100%
Other

Automatisch

Automation · No Code Platforms

13,936

Self-hosted, no-code workflow automation that keeps your data on your own servers—a privacy-first alternative to Zapier with 90+ integrations.

View details
49
Repo Health
78
Technical
64
Dependency
Built with
JavaScript100%
Updated 6 months ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

10,880

A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.

View details
83
Repo Health
69
Technical
65
Dependency
Built with
TypeScript92%
Updated 2 weeks ago
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
62%
Other

Flowise

Developer Tools · Automation · No Code Platforms

55,379

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript62%
JavaScript27%
Updated 6 days ago
TypeScript
74%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,153

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
71
Dependency
Built with
TypeScript74%
HTML23%
Updated yesterday
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,186

Build and run agentic workflows across channels with YAML, tools, and RAG

View details
79
Repo Health
76
Technical
70
Dependency
Built with
TypeScript98%
Updated yesterday
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search