Giter Site home page Giter Site logo

praveenmunagapati / authentication-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from feathersjs-ecosystem/authentication

0.0 1.0 0.0 780 KB

Feathers local, token, and OAuth authentication over REST and Websockets using JSON Web Tokens (JWT) with PassportJS.

License: MIT License

JavaScript 100.00%

authentication-1's Introduction

@feathersjs/authentication

Build Status Dependency Status Maintainability Test Coverage

Greenkeeper badge Download Status Slack 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('/', feathers.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.

authentication-1's People

Contributors

ekryski avatar marshallswain avatar daffl avatar greenkeeper[bot] avatar corymsmith avatar greenkeeperio-bot avatar enten avatar codingfriend1 avatar fastlorenzo avatar bertho-zero avatar whollacsek avatar wnxhaja avatar abraaoalves avatar asdacap avatar superbarne avatar boybundit avatar chrjean avatar ccummings avatar deanmcpherson avatar eddyystop avatar naturkultur1 avatar jerfowler avatar justingreenberg avatar aboutlo avatar mmwtsn avatar beevelop avatar mcnamee avatar michaelermer avatar ahdinosaur avatar cranesandcaff avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.