Git Product home page Git Product logo

auth-review's Introduction

Boilerplate Authentication Server using bcrypt, passport, and jwt

This is a review of setting up simple authentication and route protection using passport jwt strategy. This is a secure api server that can be used for both web and mobile applications.

Getting Started

These instructions will get you a copy of the project up and running on your local machine.

> git clone https://github.com/richdurazo/auth-review
> cd auth-review
> npm install
> npm run dev

Prerequisites

This project uses Javascript, Node, Express, Mongodb, Mongoose

Built With

  • jwt - JSON Web Tokens
  • jwt-simple - JSON Web Token encode and decode module
  • bcrypt - Used to generate a salt and hash the user password
  • passport - authentication middleware for Node.js.

Authentication flows

> Sign up --> Validate email and password are not in use --> send token
> Sign in --> Verify their email and pw are correct using Local Strategy --> send token
> Authenticated request --> Validate token using JWT strategy --> give them access to protected resource

bcryt break down

saving a pw

> using bcrypt we create a salt (encryption key)
> took a password and encrypted it using a hased pasword
> then we saved the salt and the hashed password to database (mongodb)

comparing the user login pw to our db (user sign in)

> pull just the salt from the db
> use the salt (encryption key) to encrypt the user submitted pw
> compare the newly hashed password to the hashed password in our db

Acknowledgments

  • Stephen Grider and his amazing tutorials on Udemy - Advanced React and Redux

auth-review's People

Contributors

richdurazo avatar

Watchers

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