SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
  • Rate Limiting
  • Authentication vs Authorization
  • Session vs Token Based Auth
  • JWT
  • OAuth / OAuth2
  • Single Sign-On (SSO)
  • API Keys
  • OpenID Connect (OIDC)
  • CSRF
  • Input Validation
  • mTLS and Request Signing (HMAC)
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/APIs and Communication/API Security

Single Sign-On (SSO)

Log in once, and use many apps.

⏱ 12 min readIntermediateInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Single Sign-On (SSO) lets you log in once and then use many apps without typing your password again.

  • One trusted system, the identity provider (IdP), does the login for all apps.
  • Apps trust a signed proof from the IdP (a token or an assertion).
  • Common standards: OpenID Connect (OIDC) and SAML.

02Concept: What is it?

Without SSO, every app has its own username and password. People forget them and reuse weak ones. With SSO, the apps say, β€œI trust the IdP. Ask it who this person is.”

How the pieces fit
πŸ§‘You
→↓password + MFA (once)
πŸ”Identity providerIdP
→↓signed proof
πŸ“§Mail
πŸ“„Docs
πŸ’¬Chat
Identity provider Apps (service providers)
The apps never see your password. They only see the IdP's signed answer.
πŸ”Identity provider (IdP)
Knows the users, checks passwords and MFA, and issues the proof.
πŸ“±Service provider / client
The app that trusts the IdP and lets the user in.

03Real-Life Example

🍡The Theme Park Wristband
You buy a ticket at the main gate once. Inside, every ride only checks your wristband. No ride asks for your ID again. If the park cancels your ticket, the band stops working everywhere.
Theme park
SSO
Main gate
Identity provider
Showing your ID there once
Logging in once (with MFA)
Wristband
Signed token or assertion
Each ride
Each app (Mail, Docs, Chat)
Rides trust the gate
Apps trust the IdP
Park cancels your ticket
Account disabled in one place

04Why Do We Need It?

😌Easier for users
One login, no password juggling.
πŸ”’Safer
Fewer passwords to leak or reuse. Strong MFA in one place.
🧰Simple for IT
Add a new hire or remove a leaver in one place.
🧾One audit trail
See who signed in where.
πŸ†˜Fewer reset requests
Less β€œI forgot my password”.
SSO moves the hard security work to one well-guarded door instead of a hundred weak ones.

05Where Do We Use It?

🏒Company tools
Employees log in once to email, HR, chat, code and wiki.
πŸŽ“Schools and universities
One campus account for every portal.
☁️Cloud and SaaS apps
Most business apps support SSO with a company IdP.
πŸ”—Consumer β€œSign in with …”
A big account provider acts as the IdP for other sites.
πŸ›οΈGovernment and partner portals
Different organisations trust each other's logins (federation).

06Types / Parts / How It Works

Two main protocols

OpenID Connect (OIDC)
Modern, JSON and JWT
  • Built on OAuth 2.0
  • Returns an ID token (a JWT)
  • Great for web, mobile and APIs
  • Easier to build with today
SAML 2.0
Older, XML
  • Sends a signed XML assertion
  • Very common in big companies and older enterprise apps
  • Mostly browser based
  • Heavier and trickier to debug
OIDCSAML 2.0
FormatJSON / JWTXML
Proof of loginID tokenSAML assertion
Best forModern apps, mobile, SPAsEnterprise web apps
Built onOAuth 2.0Its own standard

How the β€œonce” works: two sessions

Session at the IdP
πŸͺIdP session cookieproves you logged in to the IdP
Session in each app
πŸͺApp sessioncreated after the IdP says OK
πŸ“Note
The IdP keeps its own session. When a second app redirects you there, the IdP sees the session and answers right away. That is why you are not asked for a password again.
VisualizerLog in once, open many appsOpen Mail, then Docs and Chat. Then log out everywhere and try again.
πŸ”Identity provider (IdP)You are not logged in here
↕not logged in
πŸ“§Mailno session
↕not logged in
πŸ“„Docsno session
↕not logged in
πŸ’¬Chatno session
πŸ§‘You
→↓one password
πŸ”IdP
→↓signed proof
πŸ“±Many apps
Passwords typed
0
SSO keeps this at 1
Redirects to IdP
0
Apps logged in
0
of 3
Open an app. The first time, you must log in at the identity provider (IdP).

07How to Use It / Steps / Implementation

The flow with OIDC

  1. 1
    You open an app
    It has no session for you.
  2. 2
    App redirects you to the IdP
    With its client_id, a redirect_uri, scope=openid, state and a nonce.
  3. 3
    IdP checks for a session
    No session: you log in (password and MFA). Session found: it skips the login.
  4. 4
    IdP sends you back with a code
    The app swaps it for an ID token (and often an access token).
  5. 5
    App checks the ID token
    Signature, issuer, audience, expiry and nonce.
  6. 6
    App creates its own session
    Now you are in. Open the next app and repeat from step 2 with no password.

Rolling it out

  1. Choose an IdP (a hosted one is usually safest).
  2. Turn on MFA at the IdP.
  3. Register each app with the IdP (redirect URIs, keys).
  4. Map IdP groups to app roles, so authorization stays consistent.
  5. Plan logout: decide how apps end their sessions (single logout is hard).
  6. Keep a break-glass admin account in case the IdP is down.

08Key Terms to Know

TermMeaning in easy words
IdPIdentity provider: the system that logs users in
SP / Client / Relying partyThe app that trusts the IdP
AssertionSAML's signed statement about the user
ID tokenOIDC's signed token (a JWT) about the user
FederationTrust between separate organisations' identity systems
SCIMA standard to create and remove user accounts in apps automatically (general idea)
MFAExtra proof besides a password
Single logoutEnding the sessions in all apps when you sign out once
nonceA one-time value that stops an ID token from being replayed
Break-glass accountAn emergency admin account that does not use the IdP

09Pros, Cons and Trade-offs

βœ… Pros
  • One login for many apps
  • Strong MFA and policies in one place
  • Instant account removal for leavers
  • Fewer weak and reused passwords
  • Central audit log
⚠️ Cons
  • The IdP is a single point of failure: if it is down, nobody logs in
  • If the IdP account is stolen, every app is exposed
  • Setup and testing take effort
  • Single logout is tricky
  • Each app still needs its own authorization rules

Trade-offs

ChoiceWe gainWe lose
Long IdP sessionFewer loginsA bigger window if a laptop is stolen
Strict MFA on every loginStronger securityMore friction
Hosted IdPLess work, high uptimeCost and vendor dependency
Own IdPControlYou must run and secure it

10Common Problems and Mistakes

Common mistakes

  1. One IdP with no backup plan. Run it highly available and keep a break-glass account.
  2. No MFA at the IdP. One stolen password opens everything.
  3. Not validating the token. Check signature, issuer, audience, expiry and nonce.
  4. Treating SSO as authorization. It tells you who the user is, not what they may do.
  5. Forgetting to remove access. Disable accounts in the IdP and remove old app-local accounts.
  6. Assuming logout works everywhere. Test it.
πŸ”₯IdP outage
Everyone is locked out of everything.
πŸ”Redirect loops
Misconfigured URIs or cookies send users round and round.
πŸ•°οΈClock drift
Tokens look expired or not yet valid if clocks differ.
πŸ‘»Orphan accounts
Old local accounts that SSO does not cover.

11Real-World Examples

🏒Company logins
Staff sign in once to email, chat, code and HR tools through the company IdP.
πŸ”΅β€œSign in with …”
A popular account provider acts as the IdP for thousands of sites, mostly via OIDC.
πŸŽ“Campus accounts
One student login for library, grades and courses.
☁️Cloud consoles
Staff reach cloud accounts through the company IdP with roles mapped to groups.
πŸ“Note
General ideas only. Real setups differ in protocol, session length and logout rules.
Second app, no password
πŸ§‘You open Docs
→↓redirect
πŸ”IdPsession found βœ“
→↓signed proof
πŸ“„Docsyou are in
The IdP session is already there, so the second trip is almost instant.

12Related Topics to Read Next

OAuth / OAuth2β†’

OIDC, the modern SSO protocol, is built on OAuth 2.0.

JWT→

The OIDC ID token is a JWT.

Authentication vs Authorization→

SSO handles authentication. Each app still decides authorization.

Session vs Token Based Auth→

Each app still keeps its own session after SSO.

Single Point of Failure (SPOF)β†’

The IdP can be one, so plan for it.

Availability→

Keep the IdP highly available.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”What: log in once at an IdP and use many apps.
  • βœ”Roles: IdP (logs you in) and apps (trust the IdP).
  • βœ”Protocols: OIDC (JSON, JWT, on OAuth) and SAML (XML).
  • βœ”Why instant: the IdP has its own session cookie.
  • βœ”Risk: IdP is a single point of failure and a rich target. Use MFA and high availability.
  • βœ”SSO β‰  authorization. Apps still decide what you may do.
  • βœ”Hard part: single logout.
  • βœ”One line: β€œOne strong front door, many rooms that trust it.”
← Previous
OAuth / OAuth2
Next β†’
API Keys