Every other Friday, I have coffee with a friend who works in IT at a mid-sized company. Usually we talk about football, side projects, and which framework will be dead next year.
Last time, my friend sat down, didn't even touch the cup, and said:
"We got phished. And we had MFA."
Then, after a pause: "I don't get it. We did everything right."
That conversation lasted two hours and three coffees. I ended up drawing on a napkin. On the way home I thought: if a smart IT person is this confused, a lot of people must be. So here's the napkin, cleaned up.
What happened
Someone in their accounting team got an email: "A shared invoice is waiting, sign in to view it." The link opened a page that looked exactly like their Microsoft login. Same logo, same font, same little loading dots.
She typed her password. Then she received an SMS code, a real one, from her real company, and typed that too.
Twenty seconds later, the attacker was in her mailbox. They set up a rule forwarding every invoice to a Gmail address. That's how IT noticed, two days later.
"She didn't do anything stupid," my friend kept saying. And that's the point. She didn't.
Napkin #1: the page wasn't fake, it was a mirror
The first thing I drew was this:
This is called AiTM phishing (Adversary-in-the-Middle). The fake page doesn't just store your password. It sits between you and the real login page and forwards everything, live. The real server sees a perfectly valid login: right password, right code. And it hands the session cookie over to the attacker.
"So our MFA was useless?" my friend asked.
Not useless. It blocks the attacker who bought a list of leaked passwords. It doesn't block someone relaying your login in real time. Those kits are sold as a service now, with a monthly subscription and customer support. You don't need to be a genius to run one.
The rule I wrote under the drawing: anything a human can type, a human can type in the wrong place.
Napkin #2: "Should we switch from SAML to OIDC?"
That was the next question. Their security consultant had mentioned OIDC was "more modern", someone else wanted to replace SMS with an authenticator app, and it was all getting mixed up.
So I drew a nightclub. 🎟️
- The bouncer checks your ID at the door. That's authentication: are you really you? Password, OTP, fingerprint... these are the ways the bouncer checks.
- Once you're in, you get a wristband. Every bar inside trusts it, nobody checks your ID again. That's federation. SAML and OIDC are two kinds of wristband.
- The front desk that checks IDs and hands out wristbands is the IdP (Identity Provider).
"So SAML versus OTP is a nonsense question," my friend said. Exactly. One is the wristband, the other is the ID check. You need both, and switching wristbands doesn't fix a bouncer who can be fooled.
SAML, the old wristband (2005)
XML. The IdP sends your app a signed document: "this is Alice, finance group, valid for 5 minutes." It usually travels through the browser as an auto-submitted form.
It's everywhere in big companies and it works. But verifying XML signatures correctly is hard. In 2024 and 2025, ruby-saml (behind GitLab's SAML login, among others) had critical bugs where two XML parsers read the same document differently, letting an attacker log in as anyone.
My advice: SAML is fine, as long as you never write your own parser.
OIDC, the new wristband (2014)
Built on OAuth 2.0. JSON and JWT instead of XML. It's what's behind "Sign in with Google", and it's much nicer for SPAs, mobile apps and APIs.
For anything new: Authorization Code flow + PKCE. If a tutorial tells you to use the "implicit flow" and grab the token from the URL, close the tab. It's deprecated, and OAuth 2.1 drops it.
OTP, one way of checking IDs
Authenticator apps (TOTP), HOTP, SMS, email codes. It's a factor, not a protocol. It made stolen passwords far less useful, and I won't bash it.
But as my friend's accountant learned: an OTP is a second password that expires quickly. Quick enough to beat a leaked database. Not quick enough to beat a live relay.
| SAML 2.0 | OIDC | OTP | |
|---|---|---|---|
| Nightclub version | Old wristband | New wristband | One way to check your ID |
| What it is | Federation protocol | Federation protocol | Authentication factor |
| Format | Signed XML | JSON / JWT | 6-digit code |
| Good for | Enterprise SSO, legacy apps | Web, SPA, mobile, APIs | Second factor |
| Classic trap | Signature validation bugs | Wildcard redirects, tokens in localStorage | Phishing, SIM swap |
Napkin #3: "We have logins everywhere"
Then my friend admitted the other problem. After the incident, they listed every internal app with a login. There were way more than they expected. Some used the company SSO, some had their own users table, and changing a rule meant touching each one.
That's where an IdP like Keycloak makes sense. It's open source, it speaks SAML and OIDC, so old apps keep SAML and new ones use OIDC, on the same SSO session. It plugs into an existing Active Directory, so nobody recreates their account. And when an account is compromised, you disable it once and every session dies, everywhere.
To try it in five minutes:
docker run -p 8080:8080 \
-e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:latest start-dev
(Pin a real version in production. latest in prod is how you get surprised on a Friday.)
I told my friend: the first thing I'd check in any setup is the redirect URIs. If you see this, fix it today:
"redirectUris": ["*"]
A wildcard means anyone can ask the IdP to send the authorization code to their site. Here's what a SPA client should look like:
{
"clientId": "my-spa",
"publicClient": true,
"standardFlowEnabled": true,
"implicitFlowEnabled": false,
"directAccessGrantsEnabled": false,
"redirectUris": ["https://app.example.com/callback"],
"webOrigins": ["https://app.example.com"],
"attributes": {
"pkce.code.challenge.method": "S256"
}
}
No implicit flow. No password grant (your app should never see the user's password). Exact redirect URIs. PKCE required. That's 80% of the job.
Napkin #4: the one my friend didn't believe
"Fine," my friend said, "but even with Keycloak, the mirror page can still relay a password and a code."
True. Centralizing doesn't fix that. So I said the word: passkeys.
The look I got was the same look I get from everyone: "No password at all? That sounds like less security."
I get it. It sounds like removing the lock. It's actually replacing it with one that can't be picked.
In plain words: when you register a passkey, your phone or laptop creates two keys. The private one never leaves your device. The server only keeps the public one. When you log in, the server sends a challenge, your device signs it after you touch the fingerprint sensor or look at the camera, and the server checks the signature.
And here's what would have saved the accountant: a passkey is tied to the real domain. On login-micros0ft-secure.com, the browser simply won't offer it. No code to type, nothing to relay. The mirror page gets nothing.
Bonus: if the database leaks, the attacker gets a pile of public keys. Useless.
Keycloak supports it natively. Roughly (menu names move a bit between versions):
-
Authentication → Policies → WebAuthn Passwordless Policy: set User Verification Requirement to
required. - Duplicate the
browserflow and add the WebAuthn Passwordless authenticator. - Enable the Webauthn Register Passwordless required action, so people enroll at their next login.
- Bind the new flow to the realm.
My advice: start with the team that got hit. Offer passkeys next to the password first, then make them mandatory for the sensitive roles.
The text I got three weeks later
My friend texted me a screenshot of their Keycloak config, then: "Finance is on passkeys. The guy who complained the most now asks why the other tools don't do it."
Then, a week after: "Our CTO dropped his phone in a lake. Only passkey. Locked out. 🙃"
That's the last thing I want you to take from this post. Once you go passwordless, attackers move to "I lost my device." If your recovery process is "call support and give your date of birth", you've just moved the front door to the helpdesk. And attackers are very good on the phone, now with AI-cloned voices too.
What I suggested:
- everyone registers at least two passkeys (phone + laptop, or a hardware key in a drawer),
- recovery is as strict as login: identity check, a delay, a notification to the user,
- the helpdesk has one rule: never reset a factor based on a phone call alone. Even if it sounds like the CEO. Especially if it sounds like the CEO.
The CTO got back in. He now has a YubiKey on his keychain, and apparently mentions it in every meeting.
What I'd want you to remember
SAML and OIDC pass your identity between apps. OTP is one way to check it. An IdP like Keycloak puts it all in one place you can actually control.
But the attacks that hurt today don't crack anything. They impersonate. And against impersonation, the only factors that hold are the ones with nothing to type into the wrong page.
My friend's company had MFA. They still got phished. If you're still sending SMS codes to your users, no judgment, most of us are. But maybe put "try passkeys" in your next sprint before you need a coffee like that one.
Details changed to keep my friend's company anonymous. Did you roll out passkeys? Did someone on your team also drop their phone in a lake? Tell me in the comments.





Top comments (1)
The key distinction is that OTP and SMS codes are still a shared secret the proxy can relay in real time, so a convincing clone can ride the victim's session straight through the second factor. Passkeys sidestep that because the assertion is bound to the origin and held on the device, so a lookalike domain can't replay it to the real service. Worth pairing that with conditional access and device attestation where the risk is high, rather than treating any second factor as equivalent.