Digital Guard — Auth

Guard your app's door: 12 levels of login, hashing, tokens, JWT, CSRF and XSS. An auth security game for fullstack developers.

What you learn in this game

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.

What the levels ask

  1. Put the login steps in the right order.
  2. How does the server store and verify a password safely?
  3. Lay out the session-based authentication flow.
  4. How is a JWT made and sent to the client?
  5. How does the server verify a JWT the client sends?
  6. The access token has expired. How do you get a new one without logging in again?
  7. Log in with a third-party account. Lay out the OAuth Authorization Code flow with PKCE.
  8. The browser sends a preflight first. Lay out the CORS flow.
  9. Protect a form from Cross-Site Request Forgery.
  10. Lay out the permission check based on the user's role.
  11. Lay out the MFA (2FA) flow with a TOTP code.
  12. Lay out the whole flow from sign-up to a protected API call.