Lesson 3.1

Authentication with tokens

A signed token lets you verify the caller without a database lookup per request.

24mBeginner14.5k students

Overview

Establishing who is calling

A signed token lets you verify the caller without a database lookup per request. Verify the signature, the issuer, the audience, and the expiry — skipping any of those turns the token into a decorative header.

Short-lived access tokens with a refresh mechanism limit the damage from a leaked token. A token valid for a year is a password with worse handling.

Storage on the client is the weak point. A token in local storage is readable by any script that gets injected; an http-only cookie is not, at the cost of needing cross-site request protection.

In this lesson you will:

  • Verify a token on every request
  • Keep access tokens short-lived
  • Store credentials safely on the client

Resources

Previous Lesson
Next Lesson
Authentication with tokens — API Design with Node.js — Vertex