RP vs Provider
Aero2 serves two distinct roles in the authentication ecosystem. Understanding when it acts as each is key to using it effectively.
Aero2 as Provider (OP)
When your application uses Aero2 to authenticate users, Aero2 acts as the OpenID Connect Provider (OP).
Your app → redirects to Aero2 → Aero2 authenticates the user → returns tokens to your app
Use this when:
- You're building an app that needs user authentication
- You want to issue your own access tokens
- You need OIDC-standard tokens for API authorization
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>
Aero2 as Relying Party (RP)
When a user signs in with GitHub, Google, or another external provider, Aero2 acts as the Relying Party (RP).
User → clicks "Sign in with GitHub" on Aero2 → Aero2 redirects to GitHub → GitHub authenticates → Aero2 creates a local session
Use this when:
- You want users to sign in with their existing accounts (GitHub, Google, etc.)
- You're configuring social login for Aero2 itself
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
Both Roles Together
In practice, both roles work together:
- User visits your app → Your app redirects to Aero2 (Aero2 = Provider)
- User clicks "Sign in with GitHub" → Aero2 redirects to GitHub (Aero2 = Relying Party)
- GitHub authenticates the user → GitHub redirects back to Aero2
- Aero2 creates a session → Aero2 issues tokens back to your app
Your App → Aero2 (Provider) → GitHub (External IdP)
↓
Your App ← Aero2 (Provider) ← Aero2 (Relying Party)API Endpoints by Role
| Role | Endpoints | Purpose |
|---|---|---|
| Provider | /oauth2/authorize, /oauth2/token, /oauth2/userinfo | Issue tokens for your apps |
| Relying Party | /rp/authorize, /rp/callback/:idp | Sign in with external IdPs |
| Both | /.well-known/openid-configuration, /oauth2/jwks.json | Discovery and key verification |