OAuth Relay — Auth

Order the OAuth Code Flow steps so the token arrives without an intruder intercepting it: 14 levels of OAuth 2.0, PKCE and token exchange.

What you learn in this game

Lumbung Road has three places. A villager's house is the app. The village office is the provider that knows who you are (OAuth calls it the authorization server). The rice barn keeps the rice and serves only passes from the village office (the resource server). Every message the app sends is run on foot like a relay baton. What it carries is written on the baton: the real parameters sent over the network, recorded from a real OpenID provider and a real client. Lay out the steps, then run them: the baton falls at the step that does not have what it needs yet.

What the levels ask

  1. The Jatah Beras app keeps its secret on its server, so it uses an authorization code: Mrs. Sari goes to the village office, comes home with a code, and the house exchanges it for a pass. Lay out the relay until the rice barn answers.
  2. The old app on Mrs. Ijah's phone (jatah-beras-lama) uses implicit: with no exchange step, the village office sends the pass straight home in the address fragment (#access_token=…). Lay out the relay, then see what a village office that follows RFC 9700 answers.
  3. Dina's phone app jatah-beras-hp cannot keep a secret, so it uses PKCE: a random code_verifier, the code_challenge when asking permission, then the verifier when exchanging the code. The challenge is really computed on this page.
  4. The stock board at Mrs. Yanti's shop reads the rice barn's stock every morning. No villager signs in: the machine itself asks for a pass with its client_id and its secret (client credentials), then reads /stok.
  5. Mr. Harun opens the app an hour after signing in. His pass is stale, but the house keeps a refresh_token. Lay out the relay: the barn refuses the old pass, the house refreshes it at the village office without Mr. Harun signing in again, then tries again.
  6. The TV at Grandma Marni's house has no keyboard. The TV asks the village office for a code, shows the user_code, and Grandma Marni approves it at the village office while the TV keeps asking. Lay out the relay until the TV holds a pass.
  7. Mr. Bayu signs in with scope=openid, so the village office also gives an id_token: a letter saying who signed in. Before the house trusts that letter, and before it uses the pass from the same answer, the house checks it. The checks really run on this page.
  8. The old kartu-beras app at Mr. Piksel's internet cafe uses a pass that is a random number, not a JWT: the rice barn cannot read it by itself. Lay out the relay: the rice barn asks the village office whether that pass is still active before it answers.
  9. Mrs. Lastri signs out of the kartu-beras app, and the house hands her refresh_token back to the village office (revocation). After that an old window at the house still tries the rice barn with the old pass. Lay out the relay until the rice barn refuses.
  10. The neighbourhood head uses the Jatah Beras app. The house makes a random state, sends it to the village office, and before exchanging the code checks that the state coming home is the one it sent. Lay out the relay.
  11. Rara uses a phone app with every safeguard: the verifier, challenge and state are made first, the state is compared on the way home, and the verifier is brought along for the exchange. Lay out the whole relay until the rice barn answers.
  12. Bagas uses the phone app, a public app. Every time he refreshes his pass, the village office gives him a new refresh_token and marks the old one as used (rotation). Lay out two refreshes in a row, then ask for the ration with the newest pass.

And more, 14 levels in all.