{"id":13681901,"url":"https://github.com/jaredhanson/passport-local","last_synced_at":"2025-05-13T17:06:40.728Z","repository":{"id":1755099,"uuid":"2587163","full_name":"jaredhanson/passport-local","owner":"jaredhanson","description":"Username and password authentication strategy for Passport and Node.js.","archived":false,"fork":false,"pushed_at":"2024-02-09T08:59:23.000Z","size":105,"stargazers_count":2752,"open_issues_count":61,"forks_count":502,"subscribers_count":55,"default_branch":"master","last_synced_at":"2025-04-23T23:00:07.526Z","etag":null,"topics":["passport","password"],"latest_commit_sha":null,"homepage":"https://www.passportjs.org/packages/passport-local/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-local\u0026utm_content=about","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredhanson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jaredhanson"}},"created_at":"2011-10-16T17:26:25.000Z","updated_at":"2025-04-21T20:28:48.000Z","dependencies_parsed_at":"2024-01-22T19:33:49.352Z","dependency_job_id":"264677c3-c2b8-4249-af40-c37b2e51f086","html_url":"https://github.com/jaredhanson/passport-local","commit_stats":{"total_commits":121,"total_committers":16,"mean_commits":7.5625,"dds":0.1900826446280992,"last_synced_commit":"6045c1cd62a1e6e56afe851eb7304549a597ac23"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-local","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-local/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-local/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-local/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredhanson","download_url":"https://codeload.github.com/jaredhanson/passport-local/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528731,"owners_count":21445516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["passport","password"],"created_at":"2024-08-02T13:01:37.542Z","updated_at":"2025-04-23T23:00:18.058Z","avatar_url":"https://github.com/jaredhanson.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jaredhanson"],"categories":["JavaScript"],"sub_categories":[],"readme":"# passport-local\n\n[Passport](https://www.passportjs.org/) strategy for authenticating with a\nusername and password.\n\nThis module lets you authenticate using a username and password in your Node.js\napplications.  By plugging into Passport, password-based sign in can be easily\nand unobtrusively integrated into any application or framework that supports\n[Connect](https://github.com/senchalabs/connect#readme)-style middleware, including\n[Express](https://expressjs.com/).\n\n\u003cdiv align=\"center\"\u003e\n\n:seedling: [Tutorial](https://www.passportjs.org/tutorials/password/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-local\u0026utm_content=nav-tutorial) •\n:dart: [How-to](https://www.passportjs.org/howtos/password/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-local\u0026utm_content=nav-howto) •\n:hammer_and_wrench: [API Reference](https://www.passportjs.org/api/passport-local/1.x/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-local\u0026utm_content=nav-api) •\n:heart: [Sponsors](https://www.passportjs.org/sponsors/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-local\u0026utm_content=nav-sponsors)\n\n\u003c/div\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003csup\u003eAdvertisement\u003c/sup\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://www.tkqlhce.com/click-8907558-13433666?sid=cuHsLFjXqeyT2iHbYYaHMuw\" target=\"_top\"\u003e1Password, the only password manager you should trust.\u003c/a\u003e Industry-leading security and award winning design.\n\u003c/p\u003e\n\n---\n\n[![npm](https://img.shields.io/npm/v/passport-local.svg)](https://www.npmjs.com/package/passport-local)\n[![build](https://img.shields.io/travis/jaredhanson/passport-local.svg)](https://travis-ci.org/jaredhanson/passport-local)\n[![coverage](https://img.shields.io/coveralls/jaredhanson/passport-local.svg)](https://coveralls.io/github/jaredhanson/passport-local)\n[...](https://github.com/jaredhanson/passport-local/wiki/Status)\n\n## Install\n\n```bash\n$ npm install passport-local\n```\n\n## Usage\n\n#### Configure Strategy\n\nThe local authentication strategy authenticates users using a username and\npassword.  The strategy requires a `verify` callback, which accepts these\ncredentials and calls `done` providing a user.\n\n```js\npassport.use(new LocalStrategy(\n  function(username, password, done) {\n    User.findOne({ username: username }, function (err, user) {\n      if (err) { return done(err); }\n      if (!user) { return done(null, false); }\n      if (!user.verifyPassword(password)) { return done(null, false); }\n      return done(null, user);\n    });\n  }\n));\n```\n\n##### Available Options\n\nThis strategy takes an optional options hash before the function, e.g. `new LocalStrategy({/* options */, callback})`.\n\nThe available options are:\n\n* `usernameField` - Optional, defaults to 'username'\n* `passwordField` - Optional, defaults to 'password'\n\nBoth fields define the name of the properties in the POST body that are sent to the server.\n\n#### Parameters\n\nBy default, `LocalStrategy` expects to find credentials in parameters\nnamed username and password. If your site prefers to name these fields\ndifferently, options are available to change the defaults.\n\n    passport.use(new LocalStrategy({\n        usernameField: 'email',\n        passwordField: 'passwd',\n        session: false\n      },\n      function(username, password, done) {\n        // ...\n      }\n    ));\n\nWhen session support is not necessary, it can be safely disabled by\nsetting the `session` option to false.\n\nThe verify callback can be supplied with the `request` object by setting\nthe `passReqToCallback` option to true, and changing callback arguments\naccordingly.\n\n    passport.use(new LocalStrategy({\n        usernameField: 'email',\n        passwordField: 'passwd',\n        passReqToCallback: true,\n        session: false\n      },\n      function(req, username, password, done) {\n        // request object is now first argument\n        // ...\n      }\n    ));\n\n#### Authenticate Requests\n\nUse `passport.authenticate()`, specifying the `'local'` strategy, to\nauthenticate requests.\n\nFor example, as route middleware in an [Express](http://expressjs.com/)\napplication:\n\n```js\napp.post('/login', \n  passport.authenticate('local', { failureRedirect: '/login' }),\n  function(req, res) {\n    res.redirect('/');\n  });\n```\n\n## Examples\n\n* [express-4.x-local-example](https://github.com/passport/express-4.x-local-example)\n\n  Illustrates how to use the password strategy within an [Express](https://expressjs.com)\n  application.\n\nAdditional examples can be found on the [wiki](https://github.com/jaredhanson/passport-local/wiki/Examples).\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2011-2015 Jared Hanson \u003c[http://jaredhanson.net/](http://jaredhanson.net/)\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-local","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredhanson%2Fpassport-local","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-local/lists"}