SystemDesignDraw Logo
SystemDesignDraw

Architecture Whiteboard & Math

Identity & SecurityIntermediate Difficulty8 min read

Design OAuth 2.0 & OpenID Connect Social Login

Social Login enables users to authenticate with trusted Identity Providers (Google, GitHub, Apple) via OAuth 2.0 and OpenID Connect. It replaces password storage liability with cryptographic token verification while eliminating signup friction.

Estimated Traffic5,000 Logins/sec • 25,000 Token Checks/sec
5-Year Data Footprint8 Terabytes (User Accounts & Refresh Tokens)
Target Latency< 15 milliseconds
Availability Target99.99% (4 Nines)
Need custom numbers for your interview?Calculate QPS & capacity in System Design Cheat Sheet →

Live Architecture Studio

Edit components, modify labels, add databases, or redraw connections directly on this canvas:

Browse Component Stencils & Icons →

1. Problem & Challenge

Users abandon apps with long registration forms and password rules. Storing passwords carries massive breach liabilities. The system must let users authenticate via external providers, exchange secure authorization codes without interception, and establish stateful or JWT app sessions.

2. Core Building Blocks & Responsibilities

👉 Swipe table horizontally to view roles and responsibilities
ComponentRolePlain-English Explanation
Client Web BrowserLogin Initiator & PKCE AgentGenerates random PKCE code verifier and SHA-256 challenge, then redirects visitor to the identity provider.
Identity Provider (Google/GitHub)Authentication AuthorityAuthenticates user credentials, renders the consent dialog, and issues a single-use authorization code.
Redirect Callback HandlerCSRF & Code ReceiverReceives the authorization code and anti-tamper state parameter from the browser redirect.
Backend Auth ServiceBackchannel Token ExchangerMakes a direct server-to-server POST request to the provider token endpoint using client secrets.
JWKS & Token ValidatorCryptographic Signature VerifierFetches public keys from the provider JWKS endpoint to mathematically verify RS256/ES256 signatures.
User Database & Session StoreProfile Upsert & Session VaultCreates or links the local user record and issues a secure, HttpOnly session cookie.

3. Step-by-Step Request Flow

1

User Clicks Social Login

Browser generates a cryptographic code_verifier, transforms it to code_challenge via SHA-256, and redirects user to IdP consent screen.

2

User Authenticates & Consents

Identity Provider verifies user credentials, displays requested permission scopes, and issues a 1-time Authorization Code.

3

Redirect to App Callback

IdP redirects browser back to application with the authorization code and state token to prevent CSRF replay.

4

Backchannel Code Exchange

App backend exchanges the code, client secret, and PKCE verifier directly with provider /token endpoint over TLS.

5

Token Issuance & Verification

IdP verifies the PKCE challenge, issues an OIDC ID Token and Access Token. Backend verifies signature via provider JWKS.

6

Session Established

Backend upserts user profile, creates session in Redis, and sets an encrypted HttpOnly cookie in the browser.

4. Architectural Trade-offs

Decision:

Auth Code with PKCE vs Implicit Flow

Chosen: Auth Code with PKCE (RFC 7636)

Rationale: Implicit flow passes tokens in browser URL hashes where they leak into history; PKCE exchanges tokens securely via backchannel TLS.

Decision:

Pure Stateless JWT vs Hybrid Server Session

Chosen: Hybrid (HttpOnly Cookie + Redis)

Rationale: Pure client-side JWTs cannot be instantly revoked upon security incidents; hybrid permits immediate session invalidation.

Interview Tip

Always explain the difference between Authentication (OpenID Connect ID Token: Who you are) and Authorization (OAuth 2.0 Access Token: What you can do). Highlighting RFC 7636 PKCE for public clients demonstrates modern security expertise.

Distributed Architectures

Explore Related System Blueprints

View All Blueprints (19) →
Beginner Friendly6 min read

TinyURL Shortener

A URL shortener converts a long link (like a 100-character article URL) into a compact 7-character key (like tinyurl.com/xyz123) and redirects visitors in under 15 milliseconds.

Study Architecture →
Interview Favorite7 min read

API Rate Limiter

A rate limiter acts as a digital bouncer at the door of your API, ensuring each client stays within their allowed request limits (e.g. 100 requests per minute) and blocking abusive traffic.

Study Architecture →
Streaming & Media9 min read

Video Streaming CDN

Streaming high-definition video to millions of smart TVs and mobile phones requires breaking large 10GB video files into tiny 5-second chunks, encoding each into 20 different resolutions, and caching them right inside local ISP networks.

Study Architecture →
Real-Time & Geo10 min read

Uber Dispatch Engine

A real-time geospatial dispatch system matches riders with the most optimal nearby drivers using 64-bit H3 hexagonal indexing and 2-second batch optimization, minimizing city-wide pickup ETA and driver idle time.

Study Architecture →
Fintech & Ledger11 min read

Stripe Payments Ledger

A resilient financial payments architecture guarantees strict consistency (CP system) using cryptographic idempotency reservation, double-entry balanced postings, and sharded balance locks.

Study Architecture →
Real-Time & Collab9 min read

Figma Multiplayer Engine

A real-time multiplayer document engine uses stateful sticky session routing and server-authoritative operational ordering to sync 2D scene graphs across worldwide collaborators without locking.

Study Architecture →