Script Valley
Authentication From Scratch
Authentication FundamentalsLesson 1.1

What is authentication and why does it matter

authentication definition, authentication vs authorization, identity verification, trust model, HTTP statelessness, session problem

Authentication vs Authorization

Authentication answers one question: who are you? Authorization answers a different question: what are you allowed to do? Most security bugs come from confusing these two.

When a user submits a username and password, your server checks their identity โ€” that is authentication. When that same user tries to delete another user's account and your server blocks them โ€” that is authorization. They are separate concerns and should live in separate layers of your code.

Why HTTP Makes This Hard

HTTP is stateless. Every request your server receives is a blank slate โ€” it has no memory of the previous request. A user can log in on request #1, but on request #2 your server has no idea who they are unless you explicitly carry that identity forward.

Every authentication system you will ever build is a solution to this one problem: how do you prove identity across multiple stateless HTTP requests?

The Three Approaches

There are three standard answers to the stateless problem:

  • Sessions โ€” server stores identity, gives client a cookie with a session ID
  • Tokens โ€” server signs a token containing identity, client sends it on every request
  • OAuth / Delegated auth โ€” a trusted third party verifies identity on your behalf

This course covers all three. You will know when to use each and how to implement each securely from scratch.

Up next

How passwords should be stored in a database

Sign in to track progress

What is authentication and why does it matter โ€” Authentication Fundamentals โ€” Authentication From Scratch โ€” Script Valley โ€” Script Valley