reading-notes

code fellows reading notes

View on GitHub

Reading-Notes

Code Fellows Python 401

Read: 33 - Authentication & Production Server

JSON Web Tokens

when to use:

  1. Authorization
  2. Info Exchange

JWT Structure

two parts: the type of the token, and the signing algorithm

{
  "alg": "HS256",
  "typ": "JWT"
}

Payload

ex.

{
  "sub": "1234567890",
  "name": "John Doe",
  "admin": true
}

Signature

To create the signature part you have to take the encoded header, the encoded payload, a secret, the algorithm specified in the header, and sign that.

ex

HMACSHA256(
  base64UrlEncode(header) + "." +
  base64UrlEncode(payload),
  secret)

Use diagram

use diagram

Why use them

DRF JWT Authentication

https://build.vsupalov.com/django-runserver-in-production/

Optional Video: JWT with DRF

Bookmark and Review