Skip to content
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a0fcca9
Write intro
mao-sz Jun 23, 2025
e007ec4
Write intro to comparison
mao-sz Jun 28, 2025
78653cc
Write content on stateless caveats
mao-sz Jun 28, 2025
9fe0b67
Recommend authentication approach for remaining TOP projects
mao-sz Jun 28, 2025
44af6d0
Add assignment and knowledge check contents
mao-sz Jun 28, 2025
737f383
Expand on invalidation<->stale data
mao-sz Jun 28, 2025
9c59f9a
Fix typo
mao-sz Jun 28, 2025
ed494e4
Remove ineffective codespell:ignore comment
mao-sz Jun 28, 2025
1bcc6b8
Emphasise context of lesson's comparison
mao-sz Jun 29, 2025
6b6998f
Rephrase invalidating Odin token example
mao-sz Jun 29, 2025
8d529ec
Fix subsection heading levels
mao-sz Jun 29, 2025
e7cf5f2
Rephrase initial Odin demotion example
mao-sz Jun 29, 2025
5c6ddc8
Streamline wording for access/refresh tokens
mao-sz Jun 29, 2025
62708ab
Fix mythological inaccuracy
mao-sz Jun 29, 2025
6f0fa79
Fix grammar
mao-sz Jun 29, 2025
804c5b5
Merge branch 'main' into node-revamp-auth-compare
mao-sz Jul 5, 2025
ebdc6ce
Merge branch 'main' into node-revamp-auth-compare
mao-sz Jul 27, 2025
6a1aea3
Rename lesson
mao-sz Jul 27, 2025
2c1198c
Update intro/lesson overview with updated scope
mao-sz Jul 27, 2025
3e0b841
Streamline verbiage
mao-sz Jul 27, 2025
ac33332
Add section on third-party cookies
mao-sz Jul 27, 2025
bf646cc
Write section on reverse proxies
mao-sz Jul 27, 2025
ff8f2d8
Add assignment/KC questions about reverse proxy with Netlify/Vercel
mao-sz Jul 27, 2025
37d7190
Streamline verbiage
mao-sz Jul 27, 2025
547494a
Remove cryto assignment
mao-sz Sep 13, 2025
b61d2b6
Rephrase LO items to be topic overviews than learning objectives
mao-sz Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nodeJS/authentication/stateful_vs_stateless_authentication.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor grammar check. But where you said "(though this is of course sometimes an desirable security feature, like with many banking websites)." should say "sometimes a desirable security feature"

Copy link
Contributor Author

@mao-sz mao-sz Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Though you're looking at an outdated commit - the latest version has that fixed (fixed in 3e0b841).

There will have been quite a few changes since the commit you had looked at.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

JWTs are much harder to invalidate. Say you generate one with a 2-day expiry and the client then logs out, deleting it from whatever storage medium was used. The client no longer has the token but since it's just text, anyone else who has that text could continue to use it and it will still be valid until expiry. This could have been obtained via any number of malicious attack methods, including [cross-site scripting (XSS)](https://en.wikipedia.org/wiki/Cross-site_scripting) and [cross-site request forgery (CSRF)](https://en.wikipedia.org/wiki/Cross-site_request_forgery), especially if the token is stored somewhere like in local storage. At the most basic level, a pesky sibling/roommate could have gone on your computer, opened devtools, then copied down the JWT value to use on their machine.

The same applies to now-demigod Odin. His father Borr took away his "god" token but luckily, his brother Vili had a copy so now Odin can go around pretending to be a full-blown god again. Hence the lack of invalidation becomes a particular issue for stale data in tokens that may contain things like authorization data.
The same applies to now-demigod Odin. His father Borr took away his "My name is Odin and I'm a god" token but luckily his son, Loki, had a copy. So now Odin can go around pretending to be a full-blown god again. Even worse, Loki could go around pretending to be his father!

Since the server does not store the tokens, it cannot directly invalidate them without changing the secret used to sign them, but then that will invalidate *every* users' tokens. Keeping a server-side list of revoked tokens would just make things stateful (almost like a more complex version of sessions), since every authenticated request must query that revocation list before verifying any tokens. Setting a super-short expiry time like a few minutes would definitely reduce how long a malicious actor could use a stolen JWT to wreak havoc, but then that'd ruin the user experience for everyone else if they could only stay logged in for a few minutes at a time (though of course this is sometimes an intended security feature, like with many banking websites).
Since the server does not store the tokens, it cannot directly invalidate them without changing the secret used to sign them, but then that will invalidate *every* users' tokens. Keeping a server-side list of revoked tokens would just make things stateful (like a more complex version of sessions), since every authenticated request must query that revocation list before verifying any tokens. Setting a super-short expiry time like a few minutes would definitely reduce how long a malicious actor could use a stolen JWT to wreak havoc, but then that'd ruin the user experience for everyone else if they could only stay logged in for a few minutes at a time (though this is of course sometimes an desirable security feature, like with many banking websites).

#### A hybrid approach

Expand All @@ -48,7 +48,7 @@

<div class="lesson-content__panel" markdown="1">

1. Read ["Stop using JWT for sessions"](http://cryto.net/~joepie91/blog/2016/06/13/stop-using-jwt-for-sessions/) for a breakdown of why the proposed benefits of JWTs (for essentially the same thing as sessions) may not be worth the complexities and potential vulnerabilities.

Check failure on line 51 in nodeJS/authentication/stateful_vs_stateless_authentication.md

View workflow job for this annotation

GitHub Actions / Check for spelling errors

cryto ==> crypto
1. Read another take on [avoiding JWTs to implement browser sessions](https://ianlondon.github.io/posts/dont-use-jwts-for-sessions/).

</div>
Expand Down