Guard your app's door: 12 levels of login, hashing, tokens, JWT, CSRF and XSS. An auth security game for fullstack developers.
Welcome to the Satpam Digital drill. Your job is to lay out the right authentication flow: each level is one guard's routine, and the guard acts out the order you set. Careful, there is an unsafe step that opens the door for the thief.
Hashing is not encryption. Encryption can be reversed with a key; hashing is one-way and cannot be turned back. bcrypt is built for passwords: it keeps its salt and cost inside its own hash.
A JWT (JSON Web Token) has 3 parts: the Header (the algorithm), the Payload (the data) and the Signature. A JWT is not encryption: anyone can read its contents with a base64url decode. What matters is the signature, proof the token is genuine.
OAuth 2.0 uses a third-party account (Google, GitHub). The key to its safety: the authorization code is swapped by the server with the help of PKCE, not by the client. That stops an intercepted code from being used by someone else.
CSRF (Cross-Site Request Forgery): an attacker makes the victim's browser send a request to a site where the victim is logged in. A CSRF token is a random value only the server and the real page know, so a request from another site does not have the right token.