Library
11 min read

SSO vs OIDC vs SAML

Published

You open Gmail in the morning and sign in. Then you open YouTube, Google Drive and Google Calendar, and none of them asks you anything. At work, you sign in to Okta once and then Slack, Jira, Workday and AWS all open straight away. That experience has a name: single sign on, or SSO.

SSO is not a protocol. It is the result. OIDC and SAML are two different protocols that produce that result. Asking "SSO or OIDC?" is like asking "travel or train?". You travel by train. You get SSO by OIDC, or by SAML.

Your answer

You sign in to app A through Okta. Ten minutes later you open app B, which you have never used, and you are signed in without typing anything. App B has no idea who you are. Where did it find out?

Three parties, every time#

Every SSO setup has the same three roles. The names change between the two protocols, which is half of why people find this confusing.

  • You, in a browser.
  • The app you want to use. SAML calls it the service provider (SP). OIDC calls it the relying party (RP), because it relies on someone else to say who you are.
  • The identity provider (IdP), the one place that actually checks your password and your second factor. Okta, Microsoft Entra ID, Google, Keycloak.

The app never sees your password. It sends you to the identity provider, the identity provider checks you, and sends you back with a signed note that says "this is Asha, I checked". In SAML that note is called an assertion and it is XML. In OIDC it is called an ID token and it is a JWT. That is most of the difference.

Why the second app needs no password#

This is the part to understand properly, because it answers the question at the top. When you sign in at the identity provider, it sets its own session cookie on its own domain, say acme.okta.com. Every app is still a stranger. But the next time any app sends you to acme.okta.com, your browser brings that cookie along, the identity provider recognises you, and sends you straight back with a fresh assertion. The redirect takes a few hundred milliseconds and you never see a login page.

1/10 Jira has no session for you, so it cannot let you in.

So SSO is really two sessions layered on each other: one long session at the identity provider, and one per app. That also explains why single log out is famously unreliable. Signing out of Slack ends Slack's session, but Okta's session and Jira's session are still alive. Ending all of them means the identity provider has to notify every app, and SAML's and OIDC's logout specs for that are both patchily implemented.

SAML: the enterprise veteran#

SAML 2.0 was published by OASIS in 2005, before smartphones and before JSON was everywhere. The assertion is an XML document, signed with XML Signature, carried by the browser in a hidden form POST. It is verbose and the XML signature rules are subtle, which has produced a long line of "signature wrapping" bugs where an attacker moves the signed part and slips in an unsigned one. Use a well tested library. Never parse it yourself.

What SAML has is twenty years of enterprise adoption. Every corporate identity provider speaks it, and so does almost every B2B SaaS product. If a bank's IT team asks your startup "do you support SSO?", they usually mean "can we connect our SAML IdP to your app?".

OIDC: OAuth plus an ID token#

OpenID Connect (2014) is a thin identity layer on top of OAuth 2.0. OAuth on its own is about authorization: it gives an app an access token to call an API, and says nothing reliable about who the user is (see authentication vs authorization). OIDC adds the ID token, a signed JWT meant for the app itself:

json
{
  "iss": "https://accounts.google.com",
  "sub": "110248495921238986420",
  "aud": "your-client-id.apps.googleusercontent.com",
  "email": "asha@gmail.com",
  "iat": 1760774400,
  "exp": 1760778000,
  "nonce": "n-0S6_WzA2Mj"
}

The app must check that the signature is valid, iss is the identity provider it expects, aud is its own client id, exp is in the future and nonce matches the one it sent. Use sub, not email, as the user's key: emails get changed and reused, sub never does.

OIDC uses the OAuth authorization code flow with PKCE (covered in OAuth 2.0 flows), JSON instead of XML, and a discovery document at /.well-known/openid-configuration that lists every endpoint and signing key, so setup is often a single URL. It works the same in a browser, a mobile app or a CLI. "Sign in with Google" and "Sign in with Apple" are OIDC.

ChoiceWhat you gainWhat you payPick it when
SAML 2.0Every enterprise IdP supports it. Mature, well understood by IT teams.XML and XML signatures, browser only, awkward for mobile apps and APIs.B2B SaaS selling to large companies. Expect to support it.
OpenID ConnectJSON and JWTs, works for web, mobile and SPAs, discovery makes setup quick, same flow gives you API access tokens.Younger in some enterprise stacks. More choices to get right (flows, token validation).Anything new, consumer login, mobile apps, your own services.
Plain OAuth 2.0 for loginNone worth having.An access token is not proof of who the user is. Apps that treated it that way have been tricked with tokens issued to other apps.Never. Use OIDC.
Names you will hear
  • OktaHosted workforce IdP, SAML and OIDC
  • Auth0Owned by Okta, aimed at customer login
  • KeycloakOpen source IdP you host yourself
  • GoogleOIDC provider behind "Sign in with Google"
  • MiMicrosoft Entra IDFormerly Azure AD, most common in enterprises
  • AWS IAMAWS IAM Identity Center, SSO into AWS accounts
SSO logs people in. It does not create or delete them

When an employee leaves, SSO stops new logins, but the account in each app still exists, and an app session that is already open may live for days. The companion standard is SCIM, which lets the identity provider create, update and deactivate accounts in each app automatically. In an interview about B2B login, mentioning SCIM for offboarding is a strong signal.

In the interview#

The common prompt is not "explain SAML". It is a design question with SSO inside it.

Interviewer
You are building a B2B SaaS. Your first enterprise customer wants their employees to log in with their own Okta. How do you design login?
Multi tenant identity. The trap is building it for one customer.
You
Each customer organisation gets its own connection: SAML or OIDC, with their IdP's metadata URL, certificate and allowed email domains. At the login page I ask for the email first, look up the domain, and redirect to that organisation's IdP. That is called home realm discovery. When the assertion or ID token comes back, I validate the signature, issuer, audience and expiry, and map the IdP's user id to my user.
Email first, then route. Names the validation steps without being asked.
Interviewer
What if the user does not exist in your app yet?
You
Just in time provisioning: create the user on first login with a default role, since the IdP vouches for them. For deprovisioning I would add SCIM, so when they leave the company their account is deactivated here too, rather than lingering. I would also let the customer enforce SSO, so nobody in their domain can bypass it with a password, and keep one break glass admin account in case their IdP is down.
JIT, SCIM, enforcement and break glass. Four production details in one answer.
SSO, OIDC or SAML?
"Sign in with Google" on a consumer app
An HR team wants to use their Microsoft identity for Workday
You log in once and twelve internal tools just work
A mobile app needs login plus a token to call your API
A signed XML document posted by the browser

Checkpoint#

Checkpoint

1. App B signs you in without a password, though you have never used it. Why?

2. Which is true about SSO, OIDC and SAML?

3. Your app receives an OIDC ID token. Which check stops a token issued to a different app from being accepted?

Worth memorising
  • SSO is the outcome. SAML and OIDC are the protocols.
  • SAML: XML assertion, 2005, enterprise SaaS. OIDC: JWT ID token, 2014, on top of OAuth 2.0.
  • The silent second login comes from the IdP's own session cookie.
  • Validate signature, iss, aud, exp and nonce. Key users on sub, not email.
  • SCIM handles creating and removing accounts. SSO alone does not offboard anyone.
Say this in 60 seconds

Single sign on is the experience of signing in once and using many apps. It is delivered by a protocol, usually SAML or OpenID Connect. Both have three parties: the user, the app, and an identity provider that actually checks the credentials and sends the app a signed statement of who the user is. In SAML that is an XML assertion posted by the browser; in OIDC it is an ID token, a JWT, returned through the OAuth authorization code flow. The second app logs you in silently because the identity provider still has its own session cookie. SAML dominates enterprise SaaS, OIDC is the choice for anything new and for mobile. The app must validate signature, issuer, audience, expiry and nonce, and key users on the subject id. For B2B I route by email domain to each customer's IdP, provision just in time, and use SCIM so leavers are deactivated.