Lion Cipher Lab

Build a secure magic-link sign-in: single-use, short-lived, hashed at rest, and bound to the browser that asked

Why it matters

'Enter your email and we will send you a link' feels like the easy, safe option: no password to leak, nothing to remember. Many apps ship it as their main login. But a sign-in link is a password that travels by email, and every shortcut in how it is made, stored, and used turns into a way in. A token built from the email address and the time can be rebuilt by anyone. A token stored as-is in the database is a ready-made login for whoever reads a backup. A link that works twice works for the mail scanner that opened it first, for the person the email was forwarded to, and for an attacker who…

What you'll learn

Steps in this lab

  1. What a magic link is, and the six words this lab uses
  2. Set up: a folder, a terminal, and a Python check
  3. Build the app: one file, a naive mode and a hardened mode
  4. Click through it yourself: sign in from the outbox
  5. Run the checklist against both versions
  6. Properties 1 and 2: an unguessable token, stored only as a hash
  7. Property 3: single use, and why it must be ONE statement
  8. Properties 4 and 8: short expiry, and one sign-in cancels the rest
  9. Property 5: bind the link to the browser that asked
  10. Property 6: a GET must never sign in or burn the link
  11. Property 7: the same answer in the same time, plus rate limits
  12. Property 9: the token leaves no trail
  13. The judgment: what a magic link really is, and when it is not enough
  14. Honest negatives, and the checklist to keep

Open the full interactive lab →