Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

System Overview

Aero2 is a multi-tenant authentication and authorization platform built on Cloudflare Workers. A single Worker deployment handles all subdomains, serving both the developer dashboard and per-application auth pages.

Tech Stack

LayerTechnology
RuntimeCloudflare Workers (V8 isolates)
Web FrameworkHono
DatabaseCloudflare D1 (SQLite at the edge)
Stateful ObjectsDurable Objects (JWKS key management)
FrontendReact 19 + Vite
ValidationZod
Auth Librariesjose (JWT), oauth4webapi
LintingBiome
TestingVitest + @cloudflare/vitest-pool-workers, Playwright

Architecture Diagram

                         Incoming Request
                              |
                    +---------v---------+
                    | Cloudflare Worker  |
                    +-------------------+
                              |
              +---------------v----------------+
              |     Middleware Chain            |
              |  1. Subdomain Routing          |
              |  2. Security Headers           |
              |  3. CSRF Protection            |
              |  4. Authentication             |
              |  5. Authorization (RBAC)       |
              +---------------+----------------+
                              |
              +---------------v----------------+
              |     Hono Route Handlers        |
              |  - OP endpoints (/oauth2/*)    |
              |  - RP endpoints (/rp/*)        |
              |  - API endpoints (/api/*)      |
              |  - Frontend (SPA catch-all)    |
              +------+----------------+--------+
                     |                |
              +------v------+  +-----v---------+
              | D1 Database |  | Durable Objects|
              | (SQLite)    |  | (JWKS keys)    |
              +-------------+  +----------------+

Dual Role

Aero2 serves two roles simultaneously:

  • OIDC Provider (OP): Issues ID tokens, access tokens, and refresh tokens to registered OAuth clients. Implements the Authorization Code Flow with PKCE, token refresh, revocation, UserInfo, and OIDC Discovery.

  • Relying Party (RP): Delegates authentication to external identity providers (GitHub, Google, and dynamically configured OIDC/OAuth2 providers). Handles the OAuth callback, creates or links user accounts, and establishes sessions.

Multi-Tenant Design

A single deployment serves multiple applications via subdomain routing. Each application gets its own subdomain, user pool, identity providers, branding, and settings. The app_id column on all tenant-scoped tables enforces data isolation.

See Multi-Tenancy Design for the full entity model and isolation guarantees.

Key Directories

DirectoryPurpose
src/backend/Hono API routes, middleware, utilities
src/backend/middleware/Auth, RBAC, rate limiting, CSRF middleware
src/backend/utils/Token signing/verification, encryption, crypto
src/frontend/React 19 SPA (pages, components, contexts)
src/frontend/components/ui/Reusable UI component library
migrations/D1 database schema migrations (numbered SQL files)
docs/Documentation site (Nextra/MDX)
tests/Vitest unit and integration tests

Key Source Files

FilePurpose
src/backend/index.tsMain Hono app, route mounting, global middleware
src/backend/op.tsOIDC Provider endpoints (authorize, token, userinfo, revoke)
src/backend/rp.tsRelying Party endpoints (authorize redirect, callback)
src/backend/idp.tsIdentity Provider CRUD API
src/backend/clients.tsOAuth client CRUD API
src/backend/roles.tsRole and permission management API
src/backend/jwks.tsJWKS Durable Object (key generation, rotation, signing)
src/backend/middleware/auth.tsJWT verification, session validation, RBAC checks
src/backend/utils/token.tsJWT signing and verification utilities
src/backend/utils/crypto.tsPBKDF2 hashing, AES-256-GCM encryption, HMAC