{"_id":"@adamvr/feathers-authentication-local","_rev":"2-4843e0bdf92f046c699b3b1872b7dc7d","name":"@adamvr/feathers-authentication-local","description":"Local authentication strategy for feathers-authentication","dist-tags":{"latest":"0.3.4"},"versions":{"0.3.4":{"name":"@adamvr/feathers-authentication-local","description":"Local authentication strategy for feathers-authentication","version":"0.3.4","homepage":"https://github.com/feathersjs/feathers-authentication-local","main":"lib/","keywords":["feathers","feathers-plugin"],"license":"MIT","repository":{"type":"git","url":"git://github.com/feathersjs/feathers-authentication-local.git"},"author":{"name":"Feathers contributors","email":"hello@feathersjs.com","url":"https://feathersjs.com"},"contributors":[],"bugs":{"url":"https://github.com/feathersjs/feathers-authentication-local/issues"},"engines":{"node":">= 4.6.0"},"scripts":{"prepublish":"npm run compile","publish":"git push origin --tags && npm run changelog && git push origin","release:patch":"npm version patch && npm publish","release:minor":"npm version minor && npm publish","release:major":"npm version major && npm publish","changelog":"github_changelog_generator && git add CHANGELOG.md && git commit -am \"Updating changelog\"","compile":"rimraf lib/ && babel -d lib/ src/","watch":"babel --watch -d lib/ src/","lint":"semistandard src/**/*.js test/**/*.js --fix","mocha":"mocha --opts mocha.opts","coverage":"istanbul cover node_modules/mocha/bin/_mocha -- --opts mocha.opts","test":"npm run compile && npm run lint && npm run coverage","start":"npm run compile && node example/app"},"semistandard":{"sourceType":"module","env":["mocha"]},"directories":{"lib":"lib"},"dependencies":{"bcryptjs":"^2.3.0","debug":"^2.2.0","feathers-errors":"^2.4.0","lodash.get":"^4.4.2","lodash.merge":"^4.6.0","lodash.omit":"^4.5.0","lodash.pick":"^4.4.0","passport-local":"^1.0.0"},"devDependencies":{"babel-cli":"^6.16.0","babel-core":"^6.17.0","babel-plugin-add-module-exports":"^0.2.1","babel-preset-es2015":"^6.16.0","body-parser":"^1.15.2","chai":"^3.5.0","feathers":"^2.0.2","feathers-authentication":"^1.0.0","feathers-authentication-jwt":"^0.3.0","feathers-hooks":"^2.0.0","feathers-memory":"^1.1.0","feathers-rest":"^1.5.2","feathers-socketio":"^2.0.0","istanbul":"^1.1.0-alpha.1","mocha":"^3.1.2","rimraf":"^2.5.4","semistandard":"^11.0.0","sinon":"^2.1.0","sinon-chai":"^2.8.0"},"gitHead":"df0432e8da6fa6b8244b21be531e71eca0afd006","_id":"@adamvr/feathers-authentication-local@0.3.4","_shasum":"a5eb3fd30d1a3a28e21488a390638b4e011e09f6","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"adamvr","email":"adamvrr@gmail.com"},"dist":{"shasum":"a5eb3fd30d1a3a28e21488a390638b4e011e09f6","tarball":"https://registry.npmjs.org/@adamvr/feathers-authentication-local/-/feathers-authentication-local-0.3.4.tgz","integrity":"sha512-xWT+9L3eNE9AdEKJgJuCcRl1a5+CwX6XjSF1LrsIlzM1anoZTPoXdpEilLxjhZuWsJ57p4jdoYhzGDU710j/cA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFwtwQb0lZdeDKT+3HjfmVEPWUtto2vMcrw4KRMOjnxBAiA4W64dSUd0709dNsrIvuFO8OlJxSDgE3dzW2cB/MT3WA=="}]},"maintainers":[{"name":"adamvr","email":"adamvrr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/feathers-authentication-local-0.3.4.tgz_1495538956593_0.08775092684663832"}}},"readme":"# feathers-authentication-local\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs/feathers-authentication-local.svg)](https://greenkeeper.io/)\n\n[![Build Status](https://travis-ci.org/feathersjs/feathers-authentication-local.png?branch=master)](https://travis-ci.org/feathersjs/feathers-authentication-local)\n[![Code Climate](https://codeclimate.com/github/feathersjs/feathers-authentication-local/badges/gpa.svg)](https://codeclimate.com/github/feathersjs/feathers-authentication-local)\n[![Test Coverage](https://codeclimate.com/github/feathersjs/feathers-authentication-local/badges/coverage.svg)](https://codeclimate.com/github/feathersjs/feathers-authentication-local/coverage)\n[![Dependency Status](https://img.shields.io/david/feathersjs/feathers-authentication-local.svg?style=flat-square)](https://david-dm.org/feathersjs/feathers-authentication-local)\n[![Download Status](https://img.shields.io/npm/dm/feathers-authentication-local.svg?style=flat-square)](https://www.npmjs.com/package/feathers-authentication-local)\n\n> Local authentication strategy for feathers-authentication using Passport without all the boilerplate.\n\n## Installation\n\n```\nnpm install feathers-authentication-local --save\n```\n\n**Note:** This is only compatibile with `feathers-authentication@1.x` and above.\n\n## Documentation\n\n<!-- Please refer to the [feathers-authentication-local documentation](http://docs.feathersjs.com/) for more details. -->\n\n## API\n\nThis module contains 3 core pieces:\n\n1. The main entry function\n2. The `hashPassword` hook \n3. The `Verifier` class\n\n### Main Initialization\n\nIn most cases initializing the `feathers-authentication-local` module is as simple as doing this:\n\n```js\napp.configure(authentication(settings));\napp.configure(local());\n```\n\nThis will pull from your global `auth` object in your config file. It will also mix in the following defaults, which can be customized.\n\n#### Default Options\n\n```js\n{\n    name: 'local', // the name to use when invoking the authentication Strategy\n    entity: 'user', // the entity that you're comparing username/password against\n    service: 'users', // the service to look up the entity\n    usernameField: 'email', // key name of username field on the request\n    passwordField: 'password', // key name of password field on the request\n    entityUsernameField: 'email', // key name of the username field on the entity (defaults to `usernameField`)\n    entityPasswordField: 'password', // key name of the password on the entity (defaults to `passwordField`)\n    passReqToCallback: true, // whether the request object should be passed to `verify`\n    session: false // whether to use sessions,\n    Verifier: Verifier // A Verifier class. Defaults to the built-in one but can be a custom one. See below for details.\n}\n```\n\n### hashPassword hook\n\nThis hook is used to hash plain text passwords before they are saved to the database. It uses the bcrypt algorithm by default but can be customized by passing your own `options.hash` function.\n\n#### Default Options\n\n```js\n{\n    passwordField: 'password', // key name of password field to look on hook.data\n    hash: 'function' // default bcrypt hash function. Takes in a password and returns a hash.\n}\n```\n\n### Verifier\n\nThis is the verification class that does the username and password verification by looking up the entity (normally a `user`) on a given service by the `usernameField` and compares the hashed password using bcrypt. It has the following methods that can all be overridden. All methods return a promise except `verify`, which has the exact same signature as [passport-local](https://github.com/jaredhanson/passport-local).\n\n```js\n{\n    constructor(app, options) // the class constructor\n    _comparePassword(entity, password) // compares password using bcrypt\n    _normalizeResult(result) // normalizes result from service to account for pagination\n    verify(req, username, password, done) // queries the service and calls the other internal functions.\n}\n```\n\n\n#### Customizing the Verifier\n\nThe `Verifier` class can be extended so that you customize it's behavior without having to rewrite and test a totally custom local Passport implementation. Although that is always an option if you don't want use this plugin.\n\nAn example of customizing the Verifier:\n\n```js\nimport local, { Verifier } from 'feathers-authentication-local';\n\nclass CustomVerifier extends Verifier {\n  // The verify function has the exact same inputs and \n  // return values as a vanilla passport strategy\n  verify(req, username, password, done) {\n    // do your custom stuff. You can call internal Verifier methods\n    // and reference this.app and this.options. This method must be implemented.\n\n    // the 'user' variable can be any truthy value\n    done(null, user);\n  }\n}\n\napp.configure(local({ Verifier: CustomVerifier }));\n```\n\n## Expected Request Data\nBy default, this strategy expects a payload in this format:\n\n```js\n{\n  strategy: 'local',\n  email: '<email>',\n  password: '<password>'\n}\n```\n\n## Complete Example\n\nHere's a basic example of a Feathers server that uses `feathers-authentication-local`. You can see a fully working example in the [example/](./example/) directory.\n\n```js\nconst feathers = require('feathers');\nconst rest = require('feathers-rest');\nconst hooks = require('feathers-hooks');\nconst memory = require('feathers-memory');\nconst bodyParser = require('body-parser');\nconst errorHandler = require('feathers-errors/handler');\nconst auth = require('feathers-authentication');\nconst local = require('feathers-authentication-local');\n\n// Initialize the application\nconst app = feathers()\n  .configure(rest())\n  .configure(hooks())\n  // Needed for parsing bodies (login)\n  .use(bodyParser.json())\n  .use(bodyParser.urlencoded({ extended: true }))\n  // Configure feathers-authentication\n  .configure(auth({ secret: 'super secret' }))\n  .configure(local())\n  .use('/users', memory())\n  .use(errorHandler());\n\napp.listen(3030);\n\nconsole.log('Feathers app started on 127.0.0.1:3030');\n```\n\n## License\n\nCopyright (c) 2016\n\nLicensed under the [MIT license](LICENSE).\n","maintainers":[{"name":"adamvr","email":"adamvrr@gmail.com"}],"time":{"modified":"2022-06-12T14:17:31.280Z","created":"2017-05-23T11:29:17.846Z","0.3.4":"2017-05-23T11:29:17.846Z"},"homepage":"https://github.com/feathersjs/feathers-authentication-local","keywords":["feathers","feathers-plugin"],"repository":{"type":"git","url":"git://github.com/feathersjs/feathers-authentication-local.git"},"contributors":[],"author":{"name":"Feathers contributors","email":"hello@feathersjs.com","url":"https://feathersjs.com"},"bugs":{"url":"https://github.com/feathersjs/feathers-authentication-local/issues"},"license":"MIT","readmeFilename":"README.md"}