Skip to content
FDFerdinand Dero Saputra
All workid

Case study — 05

OAuth system

Google and GitHub sign-in written by hand in Next.js — PKCE, revocable sessions, rate limits, and an audit log, with no auth library.

Role
Authentication · personal project
Year
2026
Stack
Next.jsSQLitePKCE

01 — Context

Auth libraries hide the decisions that matter: where the PKCE verifier lives, how a session is revoked, and where a failed login is recorded. Writing the flow by hand makes those decisions visible.

02 — Approach

  1. 01

    PKCE for Google

    The Google flow uses the authorization code grant with an S256 code challenge.

  2. 02

    Sessions you can revoke

    Sessions live in SQLite. Logout ends the current device, and logout-everywhere revokes the rest.

  3. 03

    Limits and a log

    The auth endpoints are rate limited, and every auth event is written to a log file.

03 — Outcome

Unit tests run with Vitest and end-to-end flows with Playwright. The README lists the exact redirect URIs needed for local development.

providers: Google, GitHub
2
PKCE challenge method
S256
Playwright flows
E2E
Source on GitHub
Previousdhybrid-agentNextFCopier
  • Blog
  • Contact
  • Resume

© 2026 Ferdinand Dero Saputra — built in Next.js & Tailwind

--:--Back to top ↑