MCPcopy Create free account
hub / github.com/jaredhanson/passport-local

github.com/jaredhanson/passport-local @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow

Username and password authentication strategy for Passport and Node.js.

13 symbols 19 edges 23 files ⚖ MIT 1 documented · 8% 52 cross-repo links ● updated 2y ago★ 2,75649 open issues

Browse by type

⨍ Functions 13◇ Types & classes 0
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

passport-local

Build Coverage Quality Dependencies Tips

Passport strategy for authenticating with a username and password.

This module lets you authenticate using a username and password in your Node.js applications. By plugging into Passport, local authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm install passport-local

Usage

Configure Strategy

The local authentication strategy authenticates users using a username and password. The strategy requires a verify callback, which accepts these credentials and calls done providing a user.

passport.use(new LocalStrategy(
  function(username, password, done) {
    User.findOne({ username: username }, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      if (!user.verifyPassword(password)) { return done(null, false); }
      return done(null, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'local' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.post('/login', 
  passport.authenticate('local', { failureRedirect: '/login' }),
  function(req, res) {
    res.redirect('/');
  });

Examples

For complete, working examples, refer to the multiple examples included.

Tests

$ npm install
$ npm test

Credits

License

The MIT License

Copyright (c) 2011-2014 Jared Hanson <http://jaredhanson.net/>

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 13

Languages

TypeScript100%

Modules by API surface

examples/login/app.js3 symbols
examples/express3/app.js3 symbols
examples/express3-no-connect-flash/app.js3 symbols
lib/strategy.js2 symbols
examples/express3-mongoose/app.js1 symbols
examples/express3-mongoose-rememberme/app.js1 symbols

Datastores touched

UserCollection · 1 repos
(mongodb)Database · 1 repos

For agents

$ claude mcp add --transport http codehub https://codehub.bot/mcp

One hosted endpoint, no key: your agent can search, read and trace jaredhanson/passport-local and every other graph here. Cursor, Windsurf and other clients →

⬇ download graph artifact

Ask about this repo answers extend the page