OIDC & OAuth2 Overview
OAuth2
OAuth2 is an authorization framework that lets applications access resources on behalf of a user without knowing their password. Instead of sharing credentials, the user authorizes the application, which receives a time-limited access token.
Key concepts:
- Resource Owner — The user
- Client — The application requesting access
- Authorization Server — Issues tokens (Aero2)
- Resource Server — The API being accessed
OpenID Connect (OIDC)
OpenID Connect is a layer on top of OAuth2 that adds authentication. While OAuth2 answers "what can this app access?", OIDC answers "who is this user?"
OIDC adds:
- ID tokens — JWTs containing user identity claims
- UserInfo endpoint — API to fetch user profile data
- Discovery — Standard endpoint to find provider capabilities
- Standard scopes —
openid,profile,email
How Aero2 Uses These
Aero2 implements both protocols:
| Role | Protocol | What it does |
|---|---|---|
| OIDC Provider | OAuth2 + OIDC | Issues tokens for your apps |
| Relying Party | OAuth2 | Signs users in with GitHub, Google, etc. |
As Provider
Your application redirects users to Aero2, which authenticates them and returns tokens:
Browser
Your App
Aero2
- 1Browser → Your AppUser clicks Login
- 2Your AppGenerate PKCE code_verifier + code_challengecrypto.getRandomValues() + SHA-256
- 3Your App → Aero2Redirect to /oauth2/authorize?client_id=...&redirect_uri=...&code_challenge=...&code_challenge_method=S256&response_type=code&scope=openid+profile+email
- 4Aero2 → BrowserShow login pageUser authenticates with identity provider
- 5Aero2 → Your AppRedirect to redirect_uri with code?code=abc123&state=xyz
- 6Your App → Aero2Exchange code for tokensPOST /oauth2/token grant_type=authorization_code&code=...&code_verifier=...
- 7Aero2 → Your AppReturn access_token, id_token, refresh_tokenRS256-signed JWTs
- 8Your App → Aero2Fetch user info (optional)GET /oauth2/userinfo Authorization: Bearer <access_token>
As Relying Party
Aero2 redirects users to external providers, then creates local accounts:
Browser
Aero2
External IdP
- 1Browser → Aero2User clicks Login with GitHubGET /rp/authorize?idp=github&redirect_uri=/dashboard
- 2Aero2Generate state, store in DB10-minute expiry, set HttpOnly cookie
- 3Aero2 → External IdPRedirect to GitHub authorize URL?client_id=...&redirect_uri=/rp/callback/github&state=...
- 4External IdP → BrowserUser authenticates with GitHub
- 5External IdP → Aero2Redirect back with codeGET /rp/callback/github?code=...&state=...
- 6Aero2Validate state (cookie + DB)Atomic DELETE with RETURNING prevents replay
- 7Aero2 → External IdPExchange code for access tokenPOST to GitHub token endpoint
- 8Aero2 → External IdPFetch user info from GitHubGET /user with access token
- 9Aero2Create/link local user, create session
- 10Aero2 → BrowserSet session cookie, redirect to dashboardHttpOnly, Secure, SameSite=Lax
Key Differences from Other Providers
| Feature | Aero2 | Auth0 / Okta |
|---|---|---|
| Hosting | Self-hosted, your infrastructure | SaaS |
| Multi-tenant | Built-in application isolation | Per-tenant pricing |
| Customization | Full source code access | Limited |
| PKCE | Required (S256 only) | Optional |