Skip to content

How to Build Authentication In-House: A Practitioner's Guide

Every layer of a production login and single sign-on platform, from password hashing and passkeys to OAuth, SAML, scaling, and regional data, written by someone who built one

By Deepak Gupta1 hour20 chaptersPublished

AuthenticationCIAMPasskeysOAuthSSOSecurity Engineering

A practitioner's guide for CTOs, architects, and security engineers who are building or modernizing authentication in-house. Covers the build vs buy decision, reference architecture, identity data model, Argon2id password hashing, NIST SP 800-63B-4 password policy, sessions and tokens, MFA, passkeys with WebAuthn Level 3, an OAuth 2.0 and OpenID Connect server under RFC 9700, SAML SSO and SCIM, account recovery, login defense, key rotation, scaling, data residency, compliance, operations, a launch checklist, and a phased roadmap.

Start Reading

Table of Contents

1

Should You Build Authentication In-House?

When building your own login and SSO platform is the right call, when it is an expensive mistake, what it really costs, and the middle path most teams should take.

6 min read
2

The Reference Architecture

The services and data stores of a production identity platform, what each one owns, and five design rules worth never breaking.

3 min read
3

The Identity Data Model

Separate the person from the ways they sign in: core entities, a starting PostgreSQL schema, and the rules that save years of rework.

5 min read
4

Password Hashing in 2026

Argon2id parameters from OWASP, storing and verifying hashes step by step, rehash-on-login, peppers, bcrypt traps, and migrating legacy hashes.

4 min read
5

Password Policy and Breached-Password Screening

The NIST SP 800-63B-4 password policy to implement, k-anonymity breach screening with Have I Been Pwned, failed-attempt limits, and error copy.

4 min read
6

Sessions and Tokens

Server-side sessions in hardened cookies for your own web apps, short-lived JWTs plus rotating refresh tokens across trust boundaries, and the JWT rules that prevent forgery.

5 min read
7

Multi-Factor Authentication

A pluggable factor framework, factor choices ranked by phishing resistance, TOTP per RFC 6238, recovery codes, step-up, and remembered devices.

4 min read
8

Passkeys, Step by Step

Choosing your RP ID, the WebAuthn registration and authentication ceremonies, autofill with conditional mediation, upgrading existing users, and the passkey lifecycle.

4 min read
9

Building an OAuth 2.0 and OpenID Connect Server

The endpoints to build, authorization code with PKCE step by step under RFC 9700, client authentication, ID tokens, consent, and machine and agent access.

4 min read
10

Enterprise SSO: SAML, OIDC Federation, and SCIM

Tenant connections, domain-verified routing, a ten-point SAML validation checklist, certificate rotation, OIDC federation, and SCIM and just-in-time provisioning.

4 min read
11

Social Login and Account Linking

Integrating Google, Apple, and Microsoft sign-in safely, provider quirks, and a linking decision table that prevents pre-account takeover.

3 min read
12

Signup, Recovery, and the Account Lifecycle

Signup, verification links and codes, password reset, recovery when every factor is lost, contact changes, and deletion, designed as carefully as sign-in.

4 min read
13

Defending the Login

A one-table threat model, layered rate limits that do not lock out real users, risk scoring, enumeration resistance, auth-page web security, and notifications.

4 min read
14

Keys, Secrets, and Cryptography Operations

A key inventory for an identity platform, algorithm choices, signing key rotation step by step, emergency rotation, and secrets hygiene.

3 min read
15

Infrastructure and Scaling

Capacity math for password hashing, data store choices, keeping identity off the hot path, multi-region routing, availability targets, and degraded modes.

4 min read
16

Regional Data Residency and Privacy Law

What GDPR, India's DPDP Act, and China's PIPL mean for identity architecture as of November 2026, regional cells, and the flows that leak across regions.

4 min read
17

Compliance Mapping for Identity Systems

What SOC 2, ISO 27001, PCI DSS 4.0, HIPAA, NIST SP 800-63-4, and privacy laws ask of authentication, the audit events to log from day one, and admin-side controls.

3 min read
18

Operations and User Migration

Dashboards that show attacks as they start, six incident runbooks to write before launch, migrating users in by bulk import or lazy migration, and change management.

4 min read
19

Testing and the Launch Checklist

The test suites an identity team must own and a launch checklist covering credentials, passkeys, sessions, protocols, defense, and privacy.

3 min read
20

A Phased Build Roadmap

Four phases from minimum viable login to an enterprise-grade platform, the proof each gate requires, and how to staff identity for the long run.

4 min read