Tamollyo / u3_hw_JWT_auth_study

In this deliverable, we'll learn about authentication and how it works from a high level.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authentication Study

Please take the time to read this article before proceeding.

Instructions

  • Fork and Clone

Write your answers in the space provided in this readme.

A Note on Passwords

We never store passwords in our database. Instead, we use a hashing function to create a password hash or digest. We store the password digest in our database.

JSON Web Token (JWT) Authentication

Here is a flow for using JWT for Authentication

  1. The user signs up:
  • The client creates a POST request to the /signup endpoint on the server with username, email, and password in the request body
  1. The server creates a JSON Web Token (JWT) based on a header, payload, and secret
  2. The server responds with the JWT
  3. The client saves the JWT in localStorage to persist subsequent server requests

Answer the following questions:

  1. Why do we need authentication in our Web Apps?
To establish authenticity, secure information, and make sure we don't have access to tamper with someone elses information.
  1. What is the point of a JSON Web Token? Why would we want to use it?
A JSON web token is used to securely transfer information between two parties. We want to use it because of the two mechinisms it uses to secure information, and we can establish authenticity and make sure someone can't mess with someone elses information.
  1. Why would we hash a user's password when they sign up? What's the point?
Hashing a user's password provides an extra layer of encyption and produces a signature that can be used to verify the message. 'Shared secret signing scheme"
  1. Go here. Create a JWT with the following as the payload (feel free to change the username/email):
{
  "id": "1",
  "username": "bruno",
  "email": "bruno@ga.co"
}

Paste your encoded JWT below:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEiLCJ1c2VybmFtZSI6ImJydW5vIiwiZW1haWwiOiJicnVub0BnYS5jbyJ9.sHZgRrktLbUwI3L5deiZ-8KwxW0bsg3l6FJRltLSJgs

Bonus: Read https://blog.angular-university.io/angular-jwt

Submission

Submit a pull request utilizing the PR Template

About

In this deliverable, we'll learn about authentication and how it works from a high level.