The key analogy works well. One thing I'd want in the follow-up next to logout is where the browser keeps that key. In localStorage any script on the page can read it, so a single XSS hands over the key to every door. An httpOnly cookie keeps it out of JavaScript's reach, at the cost of having to think about CSRF. For a Kanban backend it's a small decision now and an annoying migration later.
I research AI tools, APIs & agents — comparing specs, pricing and real user reports — then publish honest rankings so you don't waste money. Research-first, never sponsored fluff.
Decoded the example token — 'Thor's secret enemy' and 'I love you 3000' sitting in plain base64 is the whole lesson in one string. Anyone can read it; the signature's the only thing stopping them rewriting it. The short-lived + refresh token bit is the part I'd want the follow-up on — do you rotate the refresh token on every use, or is that a whole second post?
Ohh, thanks for cracking the code. Yep, I was tempted to add the refresh token topic here but I feel like it would be too much for a single post. For the next one? I'm thinking of a completely different topic!
Clear walkthrough of the encoding vs. signature distinction, which trips up a lot of first-time backend builds. When wiring up jwt.verify() in Node/Express, one subtle edge case worth pinning down is passing an explicit algorithms: ['HS256'] allowlist rather than trusting the token header's alg field, so alg: none or key-confusion payloads get rejected immediately. Storing those short-lived tokens in HttpOnly; SameSite=Lax cookies instead of localStorage also prevents stray client-side scripts from exfiltrating them.
Yes, I believe I did SameSite=Lax and HttpOnly on my first backend. But explicitly saying I only allow 'HS256' is new to me. It make sense actually, if not the same, the token is rejected ASAP. Thanks for the in-depth explanation!
Great framing. Knowing it's the same person and being able to prove it are different problems, and most auth bugs live in the gap between them. Nice walk through it.
fun next one to write: logout. the token stays valid until exp no matter what the user clicks, and that's usually where people first meet short expiry plus a denylist
The noobmaster69 payload in the example token was a fun touch, and keeping the distinction between base64 encoding and actual encryption clear is something a lot of JWT intros skip
Great detail article on JWT Elmar!
Thank you @francistrdev!
The key analogy works well. One thing I'd want in the follow-up next to logout is where the browser keeps that key. In localStorage any script on the page can read it, so a single XSS hands over the key to every door. An httpOnly cookie keeps it out of JavaScript's reach, at the cost of having to think about CSRF. For a Kanban backend it's a small decision now and an annoying migration later.
Right on. Been reading a lot about XSS and CSRF so everything was kind of new to me. Thanks for explaining this a bit further.
Decoded the example token — 'Thor's secret enemy' and 'I love you 3000' sitting in plain base64 is the whole lesson in one string. Anyone can read it; the signature's the only thing stopping them rewriting it. The short-lived + refresh token bit is the part I'd want the follow-up on — do you rotate the refresh token on every use, or is that a whole second post?
Ohh, thanks for cracking the code. Yep, I was tempted to add the refresh token topic here but I feel like it would be too much for a single post. For the next one? I'm thinking of a completely different topic!
Clear walkthrough of the encoding vs. signature distinction, which trips up a lot of first-time backend builds. When wiring up jwt.verify() in Node/Express, one subtle edge case worth pinning down is passing an explicit algorithms: ['HS256'] allowlist rather than trusting the token header's alg field, so alg: none or key-confusion payloads get rejected immediately. Storing those short-lived tokens in HttpOnly; SameSite=Lax cookies instead of localStorage also prevents stray client-side scripts from exfiltrating them.
Yes, I believe I did SameSite=Lax and HttpOnly on my first backend. But explicitly saying I only allow 'HS256' is new to me. It make sense actually, if not the same, the token is rejected ASAP. Thanks for the in-depth explanation!
Great framing. Knowing it's the same person and being able to prove it are different problems, and most auth bugs live in the gap between them. Nice walk through it.
fun next one to write: logout. the token stays valid until exp no matter what the user clicks, and that's usually where people first meet short expiry plus a denylist
Ohhh, I'll keep this in mind!
The noobmaster69 payload in the example token was a fun touch, and keeping the distinction between base64 encoding and actual encryption clear is something a lot of JWT intros skip
Glad that distinction came out well. Thanks @parimalmakes
I think the encoding versus encryption distinction was the clearest part for me.
Thanks! I did quite a lot of thinking of how I could translate it in real world visuals.