passport
Simple, unobtrusive authentication middleware for Node.js with 480+ pluggable strategies.
Repository Health
Technical Analysis
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 31 apps in this directory
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
Omnivore
Bookmarks Archiving · Knowledge Management · Note Taking
Self-hosted read-it-later platform with highlights, newsletters, PDFs, and seamless Obsidian and Logseq integration.
Outline
Collaboration · Knowledge Management
A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.
overleaf
Collaboration · Productivity
Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.
Plasmic
CMS · Design Tools · Low Code Platforms
The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.
Refly
AI Development · Automation · No Code Platforms
Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.
Rocket.Chat
Team Chat
The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.
Swetrix
Analytics
Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.
TaskView
Productivity · Project Management
Self-hosted project and task management platform for software teams, with Kanban boards, sprints, time tracking, GitHub/GitLab integrations, and an MCP server for AI assistants.