Lion Cipher Lab

Implement OAuth 2.0 Rich Authorization Requests (RAR, RFC 9396) — fine-grained authorization from scratch

Why it matters

Classic OAuth scopes are flat strings: "payments" is one boolean — either the token can move money or it cannot. It cannot say "transfer at most 50 EUR, once, to this one account." That gap is exactly where high-value and regulated flows (open banking, FAPI, payments) get burned: a token stolen or over-scoped can do anything the coarse scope allows. RFC 9396 Rich Authorization Requests fixes this by carrying a structured, typed grant the resource server enforces per request. Building the AS and RS yourself — and watching one token be accepted for 45 EUR and rejected for 500 — turns…

What you'll learn

Steps in this lab

  1. Why a boolean scope is not enough
  2. Make a folder and open a terminal
  3. Build the AS + RS in one file
  4. Start the server
  5. Request a token carrying authorization_details
  6. One token, four verdicts — prove the win
  7. Enforcement is the product — the named failure modes
  8. Judgment — scopes vs RAR: when each is right

Open the full interactive lab →