passport-local

Passport strategy for authenticating users with a username and password in Node.js and Express applications.

Library
npm
v1.0.0
2,754 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
42 /100 Fair
Development Activity 0
Maintenance 0
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 78
Code Quality 80
Innovation 88
Learning Curve 88

passport-local is the official Passport strategy for username-and-password authentication in Node.js. It lets you add classic password-based sign in to any application built on Connect-style middleware, including Express, by wiring a single verify callback that checks the submitted credentials against your own user store.

Because it plugs into Passport’s unified authentication framework, passport-local stays deliberately small and unopinionated: it extracts the username and password from the request, hands them to your verify function, and leaves password hashing, session handling, and user lookup entirely up to you. That separation makes it the de facto standard for local login across the Node.js ecosystem.

What You Get

  • A drop-in local strategy that integrates with Passport’s authenticate() middleware
  • A single verify-callback contract for validating credentials against any user store
  • Configurable form field names via usernameField and passwordField options
  • Optional access to the request object in the verify callback through passReqToCallback

Common Use Cases

  • Adding email/password login to an Express application
  • Authenticating API requests with credentials submitted from an HTML form
  • Building a custom sign-in flow backed by your own database and password hashing

Under The Hood

Architecture The module is a compact strategy-pattern implementation split across three files in lib/: index.js re-exports the Strategy constructor, strategy.js defines it, and utils.js holds a single lookup helper. Strategy extends passport.Strategy from the passport-strategy base via util.inherits, and its authenticate(req, options) method pulls the username and password from req.body or req.query, short-circuits with this.fail() on missing credentials, and otherwise invokes the user-supplied verify callback, routing its result through this.error, this.fail, or this.success.

Tech Stack Written in plain ES5 JavaScript with a single runtime dependency, passport-strategy (1.x), and Node’s built-in util. It declares engines.node >= 0.4.0 and uses main: ./lib. Development tooling is minimal: Mocha and Chai (with chai-passport-strategy) driven through a Makefile, plus make-node for build scaffolding.

Code Quality For its size the codebase is well covered: eight Mocha test files under test/ exercise the normal, failure, error, custom-fields, options, and passReqToCallback paths. The source is thoroughly documented with JSDoc, including annotated callback contracts and usage examples. It reflects its age with var declarations and callback-style APIs rather than modern async/await, but the logic is tight and readable.

API Design The public surface is a single constructor that accepts an optional options hash and a verify callback, throwing a TypeError when the callback is missing. Getting started requires almost no boilerplate, field names are trivially remappable, and the verify contract is consistent with the rest of the Passport ecosystem, making the developer experience approachable and predictable.

Used by 21 apps in this directory

TypeScript
85%
MIT

LibreChat

AI Assistants · Developer Tools

46,236

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
62
Dependency
Built with
TypeScript 85%
JavaScript 14%
Updated 6 days ago
TypeScript
97%
Other

Lightdash

Analytics · Data Engineering

6,196

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
97%
Other

nango

Authentication · Automation · Developer Tools

12,963

Build product integrations with AI using 800+ APIs — auth, proxy, and TypeScript functions on production-grade infrastructure.

View details
94
Repo Health
85
Technical
67
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
65%
Other

NocoDB

Databases · Low Code Platforms · No Code Platforms

65,340

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
91
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 65%
Vue 30%
Updated 6 days ago
JavaScript
88%
GPL 3.0

NodeBB

Community

15,242

Modern Node.js forum software with real-time WebSockets, multi-database support, and a plugin ecosystem — the community platform built for the open web and the Fediverse.

View details
97
Repo Health
78
Technical
70
Dependency
Built with
JavaScript 88%
Go Template 11%
Updated 6 days ago
TypeScript
26%
AGPL 3.0

Omnivore

Bookmarks Archiving · Knowledge Management · Note Taking

16,356

Self-hosted read-it-later platform with highlights, newsletters, PDFs, and seamless Obsidian and Logseq integration.

View details
90
Repo Health
74
Technical
65
Dependency
Built with
TypeScript 26%
JavaScript 24%
HTML 20%
Updated 1 weeks ago
JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,266

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
84
Repo Health
80
Technical
59
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 1 months ago
TypeScript
90%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,125

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 90%
Updated 1 weeks ago
TypeScript
89%
Other

strapi

CMS

73,368

Open-source headless CMS that auto-generates REST and GraphQL APIs from your content models, with a fully customizable admin panel you control.

View details
93
Repo Health
84
Technical
63
Dependency
Built with
TypeScript 89%
JavaScript 11%
Updated 1 weeks 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