Skip to content

Instantly share code, notes, and snippets.

@rogerwschmidt
Last active November 27, 2018 22:50
Show Gist options
  • Select an option

  • Save rogerwschmidt/67cbdf813aa1122700785e9bce77a060 to your computer and use it in GitHub Desktop.

Select an option

Save rogerwschmidt/67cbdf813aa1122700785e9bce77a060 to your computer and use it in GitHub Desktop.

Authorization and Authentication Part 2 - The authenticated strike back

Objectives

  • Explain what a token is
  • Explain what authorization is
  • Walk through the process of making sure a user is authenticated before accessing a route
  • Walk through the procees of making sure that user can only access resources that belong the them.
  • Walk through a full stack authorization process

Resources

Explain what a token is

  • With your table, create a definition of what a token is. Be prepared to share your answer

Explain what authorization is

  • With your table, create a definition of what authorization is. Be prepared to share your definition.
  • Is Authentication an integral part if Authorization. If so, why?
  • Why would Authorization be useful in a web application?

Walk through the process of making sure a user is authenticated before accessing a route

  • On the backend code, make sure you are in the master branch
  • What happens when you run the following command? Why did the response return what it did?
http :3000/protected
  • Log in to an account
http POST :3000/auth/token username="student" password="student"
  • Copy the token and place it in the command below
http :3000/protected "Authorization: Bearer <token goes here>"
  • What happened? Why?

Walk through the procees of making sure that user can only access resources that belong the them.

  • On the master branch
  • Log in to an account
http POST :3000/auth/token username="student" password="student"
  • Copy the token and place it in the command below
http :3000/protected/100 "Authorization: Bearer <token goes here>"
  • What happened? Why?
  • Copy the token and place it in the command below
http :3000/protected/<your user id> "Authorization: Bearer <token goes here>"
  • What happened? Why?

Walk through a full stack authorization process

  • What happens when you load index.html?
  • What happens when the login button is clicked with a good password?
  • What happens when the login button is clicked with a bad password?
  • Where does the token get stored?
  • What happens when protected.html is loaded without a token?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment