passport-local

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

Library
npm
v1.0.0
2,757stars
MIT License

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture78
Code Quality80
Innovation88
Learning Curve88

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
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
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,220

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
92
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated today
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
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
TypeScript
95%
MIT

HyperDX

Developer Tools · Analytics · Monitoring

9,841

Open source observability platform that unifies logs, traces, metrics, and session replays on ClickHouse — now the core of ClickStack.

View details
87
Repo Health
83
Technical
70
Dependency
Built with
TypeScript95%
Updated today
JavaScript
46%
MIT

Kutt

Analytics · Marketing

11,039

Self-hosted URL shortener with custom domains, per-link analytics, and zero build step required.

View details
77
Repo Health
62
Technical
73
Dependency
Built with
JavaScript46%
Handlebars24%
HTML16%
Updated 2 days ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Marketing · Automation

2,618

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
53
Repo Health
66
Technical
64
Dependency
Built with
TypeScript94%
Updated 1 months 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