Something went wrong. Try again.
AtAuth
Something went wrong. Try again.
Project Structure #
gateway/
src/
index.ts # Express app setup, middleware, route mounting
config.ts # Environment config with validation
routes/
auth.ts # Legacy HMAC auth flow (/auth/init, /auth/callback)
admin.ts # Admin API (Bearer + cookie auth)
admin-dashboard.ts # Server-rendered admin UI + CSRF
session.ts # Session conflict detection/resolution
token.ts # HMAC token verify/info
passkey.ts # WebAuthn registration/authentication routes
user-profile.ts # User profile page (passkey + session management)
proxy-auth.ts # Forward-auth routes + enforceAccess
email.ts # Email verification routes
mfa.ts # TOTP MFA routes
oidc/
index.ts # OIDC route aggregator
authorize.ts # OIDC authorization + AT Proto OAuth callback
token.ts # Token exchange (auth_code + refresh_token)
userinfo.ts # User claims (DID-to-handle resolution)
revoke.ts # Token revocation (RFC 7009)
logout.ts # End session endpoint
discovery.ts # .well-known/openid-configuration + JWKS
services/
database.ts # SQLite schema, migrations, all DB methods
oauth.ts # AT Protocol OAuth client (NodeOAuthClient)
oidc/ # OIDC token + key services
passkey.ts # WebAuthn credential management
email.ts # Email sending (SMTP/SES)
mfa.ts # TOTP generation/verification
middleware/
rateLimit.ts # IP-based rate limiting
utils/
hmac.ts # HMAC-SHA256 token creation/verification
errors.ts # HttpError class + factory functions
access-check.ts # Handle pattern matching + access control
proxy-auth.ts # Proxy cookie + ticket helpers
data/
oidc-presets.ts # Setup wizard presets (22 apps)
types/
index.ts # Shared TypeScript types
tests/
oidc-flow.test.ts # E2E OIDC authorization flow tests
data/ # SQLite database (runtime, gitignored)
Route Mounting Order (index.ts) #
/auth/verify— forward-auth verify (before rate limit)- Rate limit middleware
/oauth— OIDC routes (authorize, token, userinfo, revoke, logout, discovery)/auth— legacy HMAC auth + forward-auth login/callback/admin— admin API + dashboard/session— session management/token— HMAC token verify/info/passkey— WebAuthn routes/user— user profile page/email— email verification/mfa— TOTP MFA
Key Service Dependencies #
DatabaseService— used by all routesOAuthService— AT Protocol OAuth, used by auth + OIDC authorizeOIDCService— token signing/verification, used by OIDC routesPasskeyService— WebAuthn, used by passkey + OIDC authorize routesMFAService— TOTP, used by MFA routes + adminEmailService— email sending, used by email routes