You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Server generates a random string called a \"salt\" \u2014 unique to this user. The salt prevents two users with the same password from having the same stored hash, and defeats precomputed \"rainbow table\" attacks.",
90
+
'Server generates a random string called a "salt" \u2014 unique to this user. The salt prevents two users with the same password from having the same stored hash, and defeats precomputed "rainbow table" attacks.',
70
91
payload: `salt = randomBytes(16)\n\u2192 "a1b2c3d4e5f6..."\n\nWhy salt?\n Without it, every user with\n password "123456" would have the\n same hash \u2014 cracking one cracks\n them all.`,
"Server concatenates the password with the salt and runs it through a slow hash function (like bcrypt, scrypt, or argon2). The \"cost\" parameter controls how slow it is \u2014 slow enough to make brute-force impractical, fast enough to not annoy users.",
99
+
'Server concatenates the password with the salt and runs it through a slow hash function (like bcrypt, scrypt, or argon2). The "cost" parameter controls how slow it is \u2014 slow enough to make brute-force impractical, fast enough to not annoy users.',
79
100
payload: `hash = bcrypt(\n "correct-horse-battery" + "a1b2c3d4e5f6...",\n cost: 12\n)\n\n\u2192 "$2b$12$LJ3m4ks9Hx8Gk1e..."\n\nThis is a ONE-WAY function:\n hash \u2192 password is infeasible\n password \u2192 hash is easy`,
"The hashes match! The server now knows the user provided the correct password, without ever having stored it. From here, the server creates a session (see the Server Sessions+Browser Cookies flow).",
142
-
payload: `HTTP/1.1 200 OK\nSet-Cookie: session_id=s_abc123;\n HttpOnly; Secure\n\n{ "message": "Welcome back, Alice!" }\n\n\u2192 See "Server Sessions+Browser Cookies" for\n what happens next`,
162
+
"The hashes match! The server now knows the user provided the correct password, without ever having stored it. From here, the server creates a session (see the Server Sessions + Browser Cookies flow).",
"More complex to understand than passwords or shared secrets",
261
-
"Private key loss = permanent lockout (no \"forgot password\" reset)",
287
+
'Private key loss = permanent lockout (no "forgot password" reset)',
262
288
"Key management is the hard part \u2014 securely storing, rotating, and backing up keys",
263
289
"Computationally more expensive than symmetric encryption (often used as a hybrid: public-key to exchange a symmetric key, then symmetric for bulk data)",
264
290
],
265
291
},
266
292
267
-
// ── Server Sessions+Browser Cookies ──
293
+
// ── Server Sessions + Browser Cookies ──
268
294
{
269
295
id: "sessions",
270
-
title: "Server Sessions+Browser Cookies",
296
+
title: "Server Sessions + Browser Cookies",
271
297
subtitle: "Stateful: server stores session records",
"Server constructs a payload (\"claims\") and cryptographically signs it. The result is three base64-encoded parts: header.payload.signature. This is NOT encryption \u2014 anyone can read the payload. The signature just proves it hasn\u2019t been tampered with.",
635
+
'Server constructs a payload ("claims") and cryptographically signs it. The result is three base64-encoded parts: header.payload.signature. This is NOT encryption \u2014 anyone can read the payload. The signature just proves it hasn\u2019t been tampered with.',
"Server recomputes the signature from the header+payload using its secret key and checks if it matches. NO database lookup needed! This is what makes JWT \"stateless.\"",
662
+
'Server recomputes the signature from the header+payload using its secret key and checks if it matches. NO database lookup needed! This is what makes JWT "stateless."',
0 commit comments