The Wayback Machine - https://web.archive.org/web/20190310032157/https://github.com/feathersjs/authentication
Skip to content
Feathers local, token, and OAuth authentication over REST and Websockets using JSON Web Tokens (JWT) with PassportJS.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
docs Move to npm scope (#594) Oct 25, 2017
lib Remove subject from the JWT verification options (#686) Jun 29, 2018
test Fix tests to work with latest Sinon (#674) May 31, 2018
.editorconfig Upgrade to new plugin format. Nov 15, 2015
.eslintrc.yml updating the codeclimate setup (#589) Oct 23, 2017
.gitignore Update to new plugin infrastructure (#591) Oct 24, 2017
.istanbul.yml Update to new plugin infrastructure (#591) Oct 24, 2017
.npmignore Update to new plugin infrastructure (#591) Oct 24, 2017
.travis.yml Update sinon to the latest version 🚀 (#681) Jun 11, 2018
CHANGELOG.md Updating changelog Jun 29, 2018
LICENSE Upgrade to new plugin format. Nov 15, 2015
README.md Replaced feathers.static with express.static (#685) Jun 28, 2018
mocha.opts Update to new plugin infrastructure (#591) Oct 24, 2017
package-lock.json Update semistandard to the latest version 🚀 (#714) Nov 13, 2018
package.json Remove nsp check. Closes #723, #722, #721, #720, #717 Dec 16, 2018

README.md

@feathersjs/authentication

Build Status Dependency Status Maintainability Test Coverage

Greenkeeper badge Download Status

Add Authentication to your FeathersJS app.

@feathersjs/authentication adds shared PassportJS authentication for Feathers HTTP REST and WebSocket transports using JSON Web Tokens.

Installation

npm install @feathersjs/authentication --save

Quick example

const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
const socketio = require('@feathersjs/socketio');
const auth = require('@feathersjs/authentication');
const local = require('@feathersjs/authentication-local');
const jwt = require('@feathersjs/authentication-jwt');
const memory = require('feathers-memory');

const app = express(feathers());
app.configure(express.rest())
 .configure(socketio())
 .use(express.json())
 .use(express.urlencoded({ extended: true }))
 .configure(auth({ secret: 'supersecret' }))
 .configure(local())
 .configure(jwt())
 .use('/users', memory())
 .use('/', express.static(__dirname + '/public'))
 .use(express.errorHandler());

app.service('users').hooks({
  // Make sure `password` never gets sent to the client
  after: local.hooks.protect('password')
});

app.service('authentication').hooks({
 before: {
  create: [
   // You can chain multiple strategies
   auth.hooks.authenticate(['jwt', 'local'])
  ],
  remove: [
   auth.hooks.authenticate('jwt')
  ]
 }
});

// Add a hook to the user service that automatically replaces
// the password with a hash of the password before saving it.
app.service('users').hooks({
 before: {
  find: [
   auth.hooks.authenticate('jwt')
  ],
  create: [
   local.hooks.hashPassword({ passwordField: 'password' })
  ]
 }
});

const port = 3030;
let server = app.listen(port);
server.on('listening', function() {
 console.log(`Feathers application started on localhost:${port}`);
});

Documentation

Please refer to the @feathersjs/authentication API documentation for more details.

License

Copyright (c) 2018

Licensed under the MIT license.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.