knowthen / Episode-9-Ditching-Cookies-for-JSON-Web-Tokens

Source for screencast: Ditching Cookies for JSON Web Tokens
http://knowthen.com/episode-9-ditching-cookies-for-json-web-tokens/
20 stars 2 forks source link

What you'll learn in just over 10 minutes

In this tutorial screencast we'll look at how to implement JSON Web Tokens (JWT's) by building a simple single page application that leverages this simple form of Token based authentication.

We'll use Koajs on the server side, Angularjs on the client side and the jsonwebtoken package to show you the basics of JWT's in just a few minutes of your time.

A changing landscape

Browser cookies became a thing over two decades ago, and have served us well in that timespan. However a lot has changed since their inception, particularly in the last few years with the rise of the Single Page Application and API's that need to be consumed by multiple clients (Web/native/mobile/etc...).

With these shifts in the developer landscape, I think that it's time to seriously consider an alternative to cookies in certain scenarios, and in this tutorial screencast we'll learn how to use JSON Web Tokens (JWT's) a leading alternative to cookies.

What are JSON Web Tokens (JWT's)

JWT's is a token based authentication scheme which I believe is better approach than cookie based authentication in certain scenarios such as with Single Page Applications.

Here are some of the reasons I think JWT's are better:

Personally I don't think the additional protection offered by cookies is a huge win because I'm not willing to accept the premise of the argument. Here is what I mean: if your site has fallen victim to XSS then you've already lost. Granted the attacker can't get access to your session cookies, but the attacker will just move on to other attacks such as key logging and phishing. Not to mention protecting against XSS attacks is fairly well understood and most frameworks offer protection from these attacks as a default behavior.

Please join my mailing list so I can let you know when new screencasts are released

http://knowthen.com/join/