Overview
Single sign-on (SSO) lets a user authenticate once with a central identity provider (IdP) and then access many applications without logging in again. Each application (service provider) trusts the IdP's signed assertion about who the user is, instead of managing its own passwords.
Enterprise SSO typically uses SAML 2.0 (older, XML-based) or OpenID Connect (modern, JSON/JWT-based). SSO improves security (one place for MFA, password policy, and offboarding) and user experience, but makes the IdP a critical dependency: if it is down, nobody can log in.
You show your ticket and ID once at the main gate and get a wristband. Every stage and food tent checks the wristband instead of your ID. If security cuts your wristband, you lose access to everything at once.
When to use it
- Companies with many internal and SaaS applications.
- B2B SaaS selling to enterprises (customers require SSO).
- A product suite where users move between apps (Google Workspace).
- Centralized offboarding: disable one account, lose access everywhere.
Where it shows up in interviews
Recognize it when: customers want to use their own identity provider.
- Design SSO for a B2B SaaS product
- Design multi-tenant login
Recognize it when: one account across several apps.
- Design Google account login across Gmail, Drive, YouTube
Where it is used in real software
Common enterprise IdPs that federate login to thousands of SaaS apps using SAML and OIDC.
Alongside SSO, SCIM automatically creates and deactivates user accounts in apps when HR changes happen.
Many SaaS vendors put SSO only in expensive enterprise plans because it is a must-have for large customers.
Key terms
- Identity provider (IdP)
- Authenticates users and issues assertions or tokens.
- Service provider (SP)
- The application that relies on the IdP.
- SAML assertion
- A signed XML document stating who the user is and their attributes.
- Federation
- Trust between separate organizations' identity systems.
- SCIM
- Standard API for provisioning and deprovisioning users.
How it works, step by step
- 1User opens app A
App A has no session and redirects to the IdP.
- 2IdP authenticates
User logs in with password + MFA; the IdP creates its own session.
- 3IdP returns an assertion or token
Signed SAML assertion or OIDC ID token posted back to app A.
- 4App A creates a local session
After verifying the signature and audience.
- 5User opens app B
App B redirects to the IdP, which already has a session and immediately returns a token: no login prompt.
SAML vs OIDC
Both achieve SSO
| Aspect | SAML 2.0 | OpenID Connect |
|---|---|---|
| Format | XML assertions | JSON / JWT |
| Typical use | Enterprise web apps | Modern web, mobile, APIs |
| Mobile friendly | Poor | Good |
| Built on | Its own protocol | OAuth 2.0 |
NOWAspect: Format | SAML 2.0: XML assertions | OpenID Connect: JSON / JWT
New products should prefer OIDC, but B2B SaaS usually must support SAML too because many enterprises still require it.
Implementation
import { Issuer, generators } from "openid-client"; const issuer = await Issuer.discover("https://idp.example.com"); // reads .well-known/openid-configurationconst client = new issuer.Client({ client_id: "crm-app", client_secret: process.env.OIDC_SECRET!, redirect_uris: ["https://crm.example.com/callback"], response_types: ["code"],}); app.get("/login", (req, res) => { const codeVerifier = generators.codeVerifier(); req.session.codeVerifier = codeVerifier; res.redirect(client.authorizationUrl({ scope: "openid email profile", code_challenge: generators.codeChallenge(codeVerifier), code_challenge_method: "S256", }));}); app.get("/callback", async (req, res) => { const params = client.callbackParams(req); const tokens = await client.callback("https://crm.example.com/callback", params, { code_verifier: req.session.codeVerifier }); const claims = tokens.claims(); // verified ID token: sub, email, name req.session.userId = await users.upsertFromIdp(claims.sub, claims.email); res.redirect("/");});Complexity and performance
Password + MFA.
No prompt while IdP session is valid.
Trade-offs
One compromised IdP account reaches every app; enforce strong MFA and anomaly detection at the IdP.
An IdP outage blocks logins everywhere; existing app sessions keep working, so reasonable session lifetimes matter.
Variants and related techniques
Each customer configures its own IdP; the login page routes by email domain.
Logging out of the IdP signals every app to end sessions; hard to make fully reliable.
Common mistakes
- Not validating the assertion's audience and signature.
Fix: Verify issuer, audience, signature, and expiry on every login.
- Forgetting deprovisioning.
Fix: Use SCIM or short sessions so removed employees lose access quickly.
Interview questions
How does SSO work under the hood?
The application redirects to the identity provider, which authenticates the user and returns a signed assertion or ID token. The app verifies it and creates a local session. Other apps repeat the redirect, but the IdP's existing session makes it silent.
How would you add enterprise SSO to a multi-tenant SaaS?
Store per-tenant IdP configuration (SAML metadata or OIDC issuer), route login by email domain, map IdP identities to tenant users, and support SCIM for provisioning.
Practice problems
| Problem | Difficulty | What it trains |
|---|---|---|
| Explain SSO between two apps and one IdP | Easy | Redirect flow. |
| Design per-tenant SSO for a B2B product | Hard | Configuration and mapping. |