How I Learned Identity & Access Management (With Project Keycloak)
- security
- iam
- cloud
The problem every app has to solve
Every website or app you use has to answer two simple questions before it lets you do anything: who are you, and what are you allowed to do? I built a small project to understand exactly how that works behind the scenes — using the same approach real companies use to manage logins and permissions. This post explains it in plain English, no technical jargon required.
Think of it like a building with a badge office
Picture an office building where some rooms are open to everyone, some need a staff badge, and a few need a manager's badge. There's one badge office at the front — it's the only place that ever checks your ID and password. Once it knows who you are, it prints you a badge that says who you are and what kind of badge you hold.
Every door in the building then does its own simple check: it looks at your badge and decides, on the spot, whether that badge is allowed through. The doors never call the badge office to double-check — the badge itself can be trusted, because it carries a seal that every door already knows how to recognize.
In my project, Keycloak plays the role of the badge office, and the small program I wrote (a tiny API) plays the role of a building full of doors.
How it actually works, step by step
- You walk up to the badge office. You sign in once, with your username and password, at Keycloak — and only at Keycloak. The API never sees your password.
- The badge office prints your badge. Keycloak hands back a badge (a token) listing who you are and which kinds of rooms you're allowed into, stamped with its seal.
- You show the badge at a door. Every request you send to the API carries that badge along with it.
- The door checks the seal. The API confirms the seal is genuine and the badge hasn't expired — without calling the badge office.
- The door reads your badge and decides. If the badge says you're allowed into this room, the door opens.
If the badge doesn't match what a door needs, the door simply stays shut — no further questions asked, and no call back to the badge office.
What I learned (the fun surprises)
- "Not logged in" and "not allowed" are different things. Show up with no badge at all, and the door won't even consider you. Show up with a badge that's just the wrong kind, and the door looks at it and says no anyway. Same locked door, two very different reasons.
- A badge can be read by anyone holding it. The badge isn't a secret — anyone who has it can read what's printed on it. The seal only proves it's real, not that it's private.
- Your badge doesn't update itself. If your access is upgraded today, the badge already in your pocket still says the old thing until it expires and you're issued a new one. I tested this on purpose and watched it happen.
- Machines get badges too. A backend service that isn't a human still needs a badge to talk to other systems — it just gets one a different way, with no password typing involved.
Why this matters in the real world
This isn't just a learning exercise — it's the same pattern real companies use to secure their products, and it's exactly the kind of system identity and access management (IAM) teams build and maintain at scale. The same idea scales from three test users on my laptop to millions of users on AWS; only the badge office changes (from something I run myself to a managed service), while the doors barely change at all.
You can see the full code on GitHub: anu2016/iam-starter.