Code Monkey home page Code Monkey logo

jwt-passport-acl's Introduction

jwt-passport-acl

Stateless Authentication and Authorization Express, Mongoose, Passport, JWT, node-acl written in ES6

Requirements

  • Node.js >= 8.x
  • MongoDB

Configuration

global configuration server/config/config.js

Database

To establish a connection to the database, you may configure the database connection parameters in global configuration default is mongodb://localhost:27017/jwtpassauth.

JWT Secret

The JWT secret key is set in the global configuration file. Edit them to suit your needs. The JWT contains encoded information about the user and a signature that, when decoded, is validated to ensure that the token has not been tampered with.

API

Signup: /users/signup

POST /users/signup
Host: localhost:3001
Content-Type: application/json

{
    "email": "[email protected]",
    "password": "password"
}

Signin: /users/signin

POST /users/signin
Host: localhost:3001
Content-Type: application/json

{
    "email": "[email protected]",
    "password": "password"
}

Returned JSON:
{
"success": "Welcome JWT auth Passed",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InJAci5kZSIsImlhdCI6MTUzNTQ1MTg5NSwiZXhwIjozMDcwOTA3MzkwfQ.NttgaHSkIonyyn4_Ds9bl50ltF4g93CSWLLOFRJelYk"
}

Authentication server/config/authentication.js

Authentication is based on json web tokens and passwort-jwt. After a successful login the generated token is sent to the requester. To access the protected routes, the requester must sent the token in the header request.

JWT Protected: /protected

GET /protected
Host: localhost:3001
Authorization: Bearer Token 
Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InJAci5kZSIsImlhdCI6MTUzNTQ1MTg5NSwiZXhwIjozMDcwOTA3MzkwfQ.NttgaHSkIonyyn4_Ds9bl50ltF4g93CSWLLOFRJelYk

Scripts

eslint extends eslint-config-airbnb-base

$ yarn run linter

contains all of eslint-config-airbnb-base default ESLint rules, including ECMAScript 6+.
It requires eslint and eslint-plugin-import

Development start nodemon

$ yarn run serve

References

Blogs and repros about this subject that I enjoy reading.


Credits to:

jwt-passport-acl's People

Contributors

ruhartm 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.