Giter VIP home page Giter VIP logo

auth-request-flow's Introduction

Authenticating HTTP Requests

Learning Objectives

  • Use bearer token authentication to protect an API resource

Introduction

In this exercise, you're going to build a small but complete bearer token authentication system. Here's a reminder for the flow:

  1. The client sends a request containing login credentials to the server.
  2. The server checks the credentials are correct and sends back a token.
  3. The client sends a request to a secure resource, putting the token in the authorization header of the request.
  4. The server verifies that the token is valid and sends back the requested resource, or an error message if the token wasn't valid.

Here's the diagram again to help you visualise this flow:

Instructions

  1. Fork this repository and clone the fork.
  2. Run npm ci to install dependencies.
  3. Run npm start to run the application.
  4. Complete each requirement in the requirements directory in numerical order.
    1. As part of this, you will need to create an environment variable to store your secret!
    2. Copy the .env.example file and name your file .env
    3. Assign the JWT_SECRET variable some string value for your secret (e.g. JWT_TOKEN="my_super_secure_secret")
    4. You can then reference this secret by using the node process env object (e.g. const secret = process.env.JWT_SECRET)

auth-request-flow's People

Contributors

vherus avatar dearshrewdwit avatar chloe070196 avatar julesnuggy 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.