GuildCrafts / web-development-js

Craft repository for Web Development with JavaScript
http://jsdev.learnersguild.org/
Other
1 stars 1 forks source link

Basic HTTP Authentication from scratch #214

Open jaredatron opened 7 years ago

jaredatron commented 7 years ago

Basic HTTP Authentication from scratch

Learning objectives

App 1 - Storing a string in a cookies

In App 1 we're going to store a single piece of data in an HTTP cookie.

Using express, make an app that renders an html page that with a form that does a post of the users name and then store in a cookie. Parse cookies using a cookie parsing node package. Display the users name on the page if you have it in the cookie. also have a "clear name" button

Resources

Specs

App 2 - Storing data in cookies

In App 2 we're going to store more than one piece of data in a cookie using JSON.

Resources

Specs

App 3 - An insecure session

In App 3 we're going to move our cookie logic into an express middleware and use it as a session.

The express middleware should look for the session cookie and if present deserialize it. Then it should place a session object at request.session so future request handlers can access the session. It also needs to serialize the session object back into the cookie before the response headers are sent.

the session cookie, if present, and makes a session object available at request.session

Build a middleware that serializes a session object into a session cookie using JSON. look at session-cookie as a guide. Each route should have access to the deserialized session cookie object at req.session. The cookie needs to be updated on each request. Update the form to store the users name in the session cookie object under the key user_name

Resources

Specs

App 4 - A secure session

Encrypt the session cookie using bcrypt

Specs

tannerwelsh commented 7 years ago

@deadlyicon could we roll this into #194?

jason00111 commented 7 years ago

@tannerwelsh I like that this one's primary focus is authentication.

The learner will have to set up an html form and an express web server as part of the process so there's definitely overlap with #194.

tannerwelsh commented 7 years ago

Got it, thanks @jason00111. Let's keep them separate then. :)

jaredatron commented 7 years ago

Thank you @tannerwelsh !!!!