Lion Cipher Lab

Run the OAuth 2.0 Authorization Code flow with PKCE by hand

Why it matters

The authorization-code flow with PKCE is the default, recommended way to log a user into almost any modern app — every single-page app, every mobile app, and now (under OAuth 2.1) confidential web apps too. In the basics lab you watched it happen; here you drive it yourself, which is the difference between recognising the parts and being able to debug them at 2am when a login is broken. You will generate the verifier and challenge with your own hands, see the exact /authorize parameters, capture the code, trade it for real tokens at the /token endpoint, and watch the exchange FAIL the instant…

What you'll learn

Steps in this lab

  1. The attack PKCE exists to stop
  2. Start a real authorization server: Keycloak in Docker
  3. Create a realm, a user, and a PUBLIC client that requires PKCE
  4. Generate the code_verifier and the S256 code_challenge
  5. Why S256, not plain — and why you still send state
  6. Hit /authorize in the browser and capture the code
  7. Exchange the code for tokens at /token
  8. Watch PKCE work: exchange again with the WRONG verifier
  9. Decode the id_token JWT to read the claims
  10. Public vs confidential, the pro move, and when NOT to hand-roll

Open the full interactive lab →