Giter Site home page Giter Site logo

auth-i's Introduction

Authentication Project

Topics

  • Authentication.
  • Express Middleware.
  • Password Hashing.

Assignment

Part one, due Monday: Use Node.js, Express and Knex to build an API that provides Register and Login functionality using SQLite to store User information. Make sure the password is not stored as plain text.

Part two, due Tuesday: Use sessions and cookies to keep a record of logged in users across requests.

Instructions

You will build the solution from scratch, no starter code is provided. Feel free to structure your API anyway you want, but aim at making it easy to maintain in the future.

Download Project Files

  • Fork and Clone this repository.
  • CD into the folder where you cloned the repository.
  • Do your magic!

Implement Requirements

  • Take the steps necessary to create a package.json to keep a record of all dependencies.
  • Configure an npm script named "start" that will execute your code using nodemon so that the server restarts on changes. Make nodemon be a development time dependency only, it shouldn't be deployed to production.
  • Design and build a set of endpoints listed below.
  • Use Postman to test the API as you work through the exercises.

Endpoints

Method Endpoint Description
POST /api/register Creates a user using the information sent inside the body of the request. Hash the password before saving the user to the database.
POST /api/login Use the credentials sent inside the body to authenticate the user. On successful login, create a new session for the user and send back a 'Logged in' message and a cookie that contains the user id. If login fails, respond with the correct status code and the message: 'You shall not pass!'
GET /api/users If the user is logged in, respond with an array of all the users contained in the database. If the user is not logged in repond with the correct status code and the message: 'You shall not pass!'.

Stretch Problem

  • Write a piece of global middleware that ensures a user is logged in when accessing any route prefixed by /api/restricted/. For instance, /api/restricted/something, /api/restricted/other, and /api/restricted/a should all be protected by the middleware; only logged in users should be able to access these routes.
  • Build a React application that implements components to register, login and view a list of users. Gotta keep sharpening your React skills.

auth-i's People

Contributors

karthikv avatar luishrd avatar mixelpixel avatar radeleon avatar ryan-hamblin 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.