Lion Cipher Lab

Rotate refresh tokens and revoke sessions with Keycloak

Why it matters

Getting a token is the easy half of OAuth. The hard, high-stakes half is the token LIFECYCLE — what happens after issuance, when a token ages, gets refreshed, gets stolen, or has to be killed on demand. Every real breach postmortem that involves stolen credentials comes down to two questions: could the attacker keep refreshing access indefinitely, and could the defender cut the session off fast? This lab makes both answers concrete against a real authorization server. You will obtain a refresh token — the long-lived credential an app uses to get fresh access tokens without re-prompting the…

What you'll learn

Steps in this lab

  1. What a refresh token is, and why its lifecycle is the whole game
  2. Start a real authorization server: Keycloak in Docker
  3. Create a realm, a client, and a test user
  4. Get an access token AND a refresh token
  5. Decode the refresh token and read exp / typ
  6. USE the refresh token: grant_type=refresh_token
  7. Turn ON rotation and PROVE the old token is dead
  8. Watch introspection: active true, before revocation
  9. REVOKE: kill the token (RFC 7009) and the session (admin)
  10. The timers that govern every session
  11. Why this, when NOT to, and the pro way

Open the full interactive lab →