Authentication & Tokens Lab

Topical Authority Guide & Developer Workspace

Authentication validates a user's identity. Storing and transmitting these credentials requires secure protocols, including tokenized sessions, hashing algorithms, and time-based passwords.

Topic Overview

Modern web apps rely on stateless authentication systems to scale. JSON Web Tokens (JWT) allow servers to verify user claims securely without database queries on every HTTP request.

Securing credentials requires using slow hashing functions, multi-factor authentication (MFA), and secure session tokens.

The Anatomy of a JWT

A JSON Web Token consists of three base64url-encoded parts separated by periods: the Header (signing algorithm), the Payload (claims, issuer, expiration), and the Signature (security verification).

The signature guarantees that the token has not been tampered with in transit. Client applications must inspect JWT payloads to handle route access, but signature validation must happen on the server.

How Multi-Factor Authentication Works

Time-Based One-Time Passwords (TOTP) generate temporary verification codes from a shared secret. The algorithm uses the current Unix epoch time in 30-second steps to compute HMAC codes.

Because TOTP keys are generated locally, they prevent account compromise even if the primary password database is leaked.

Frequently Asked Questions

Are JWT claims encrypted by default?
No. JWT payloads are only Base64URL-encoded, which is a plaintext conversion. Anyone can decode and read JWT contents; never put passwords or sensitive data inside payloads.
How do TOTP generators stay in sync?
TOTP client apps and server backends calculate codes using the same shared secret and coordinate their steps with the global Unix time clock, tolerating short offsets.