Ridhuan Rangga KusumaRidhuan Rangga
Case StudiesSystem Design
Home
Writing

Case Study / 2026

Turion SSO: Self-Hosted OAuth 2.0 / OIDC Identity Provider & SDK

RFC-compliant OAuth 2.0 and OpenID Connect Identity Provider enforcing PKCE S256, single-use authorization codes with replay auto-revocation, TOTP MFA, and a Node.js SDK.

S256 Mandatory

PKCE Enforcement

Rejects plain or missing challenges

Auto-Revoke

Code Replay Defense

Revokes full grant on 2nd exchange

JWKS Offline

Token Verification

SPs validate JWT without IdP bottleneck

TOTP MFA

Auth Hardening

Bcrypt cost 12 + backup codes

problem

Eliminating Duplicate Auth Silos & Third-Party Lock-In

Maintaining separate user databases and login flows per product creates security policy drift and user friction, while hosted identity vendors introduce per-MAU pricing unpredictability and external custody over session logs.

architecture

OIDC Authorization Code Flow with PKCE & JWKS

interactive diagram

OIDC Authorization Code Flow with PKCE & JWKS

Service ProviderOIDC /authorizePKCE Token + JWKSPostgres + Redis

Exposes standard discovery (/.well-known/openid-configuration), enforces confidential client auth plus PKCE S256, verifies id_token signatures via JWKS through the ridhuan-sso SDK, and records every security event in PostgreSQL.

results

Security Guarantees Delivered

Delivered unified login across heterogeneous tech stacks, exact-match redirect URI enforcement, replay-attack grant revocation, and complete developer onboarding documentation.

Architecture Decisions

ADR 1 / accepted

Revoke All Issued Tokens on Authorization Code Replay

If an intercepted authorization code is replayed within its 5-minute TTL, merely returning 400 leaves already-issued tokens active.

Follow RFC 6749 section 4.1.2 guidance: mark consumed codes in Redis and revoke all descendant access and refresh tokens if a second exchange attempt occurs.