Demystifying Cookies and Tokens
Tommi Hovi explores cookies and tokens for theft prevention. Cookies store user data, while tokens like JWT manage information exchange. Understanding these is vital for web security and user experience.
Read original articleTommi Hovi delves into the world of tokens and cookies to understand and prevent theft. Cookies, small text files created by websites, store user data like preferences and session information. They are essential for HTTP session management, personalization, and tracking. Cookies have attributes like Session ID, Expires, Domain, and HttpOnly to define their behavior. Types of cookies include essential ones like Session cookies and first-party cookies, and non-essential ones like Analytics and customization cookies. On the other hand, tokens like JSON Web Tokens (JWT) are self-contained JSON objects used for information exchange between clients and servers. Tokens carry information about authentication and access rights. Some tokens are stored in cookies for security, especially HttpOnly cookies. The post also touches on protocols like OAuth 2.0 and OpenID Connect (OIDC) used for authorization in web platforms. Understanding cookies and tokens is crucial for enhancing security and user experience on websites.
I haven't needed to understand JWTs in depth, so have never spent the time to do a deep technical dive, but I'd still like to understand how they work. Every time I see a JWT article pass by, I'll jump in and find the general concepts explained but with enough technical gaps that I couldn't understand them in practical terms, especially when compared to my years of previous web-dev experience with cookies.
Also thanks to @unscaled for pointing out PASETO, which aims to fix some of the many problems with JWTs: https://paseto.io/
This claim is misguided, but I hear it quite often. JWT is a very popular (and downright terrible[1]) format, but I there is no evidence that most of the tokens use JWT. It could be worse - I've heard some people claiming with confidence that OAuth mandates JWT.
The reality is that OAuth 2.0 predates JWT, and the implicit assumption was that all tokens are stateful. The access tokens in the examples are all short, and the spec strongly recommends revoking access tokens in case of access code reuse.
This makes JWT access tokens a non-canonical implementation of OAuth 2.0. You could add a "jti" claim (or "uti" claim in case of Microsoft) and then check for revocations in Redis, but then your only achievement was bloating up your access tokens by a factor of 20. Congratulations!
That's the reason why the other Big Tech companies are not using JWT for Access Tokens. It just doesn't make sense when you are at the scale where you need access tokens to be small and moderately long-lived. Users of JWT are more heavily concentrated on the smaller scale: more recent startups and enterprise customers.
---
[1] https://paragonie.com/blog/2017/03/jwt-json-web-tokens-is-ba...
> We use cookies to ensure that we give you the best experience on our website.
> Accept | Decline
Do "non-essential" cookies actually make my experience any better? I always decline and haven't noticed a difference from the pre-GDPR days.