Skip to content

Instantly share code, notes, and snippets.

View eslachance's full-sized avatar
💻
Helping the world make better code one answer at a time!

Évelyne Lachance eslachance

💻
Helping the world make better code one answer at a time!
View GitHub Profile
@samsch
samsch / stop-using-jwts.md
Last active April 14, 2024 16:00
Stop using JWTs

Stop using JWTs!

TLDR: JWTs should not be used for keeping your user logged in. They are not designed for this purpose, they are not secure, and there is a much better tool which is designed for it: regular cookie sessions.

If you've got a bit of time to watch a presentation on it, I highly recommend this talk: https://www.youtube.com/watch?v=pYeekwv3vC4 (Note that other topics are largely skimmed over, such as CSRF protection. You should learn about other topics from other sources. Also note that "valid" usecases for JWTs at the end of the video can also be easily handled by other, better, and more secure tools. Specifically, PASETO.)

A related topic: Don't use localStorage (or sessionStorage) for authentication credentials, including JWT tokens: https://www.rdegges.com/2018/please-stop-using-local-storage/

The reason to avoid JWTs comes down to a couple different points:

  • The JWT specification is specifically designed only for very short-live tokens (~5 minute or less). Sessions
@tomhodgins
tomhodgins / same-element.html
Created April 27, 2017 13:54
Each of the ten selectors in the css below set the `color` property for the same element: the second <li>. This shows the versatility in CSS selectors and why it's hard sometimes for machines to predict which elements a style may apply to without knowing the current state of HTML
<input type=range min=0 max=100 value=100>
<input type=checkbox>
<input autofocus>
<ul>
<li>item
<li id=demo>item
<li>item
</ul>