Implement OAuth 2.0 login via GitHub as an alternative to email/password. Uses a provider registry pattern (internal/auth/oauth/) so adding Google or other providers later requires only a new Provider implementation. Flow: GET /v1/auth/oauth/github redirects to GitHub, callback exchanges the code for a user profile, upserts the user + team atomically, and redirects to the frontend with a JWT token. Key changes: - Migration: make password_hash nullable, add oauth_providers table - Provider registry with GitHubProvider (profile + email fallback) - CSRF state cookie with HMAC-SHA256 validation - Race-safe registration (23505 collision retries as login) - Startup validation: CP_PUBLIC_URL required when OAuth is configured Not fully tested — needs integration tests with a real GitHub OAuth app and end-to-end testing with the frontend callback page.
35 lines
862 B
Plaintext
35 lines
862 B
Plaintext
# Database
|
|
DATABASE_URL=postgres://wrenn:wrenn@localhost:5432/wrenn?sslmode=disable
|
|
|
|
# Control Plane
|
|
CP_LISTEN_ADDR=:8000
|
|
CP_HOST_AGENT_ADDR=localhost:50051
|
|
|
|
# Host Agent
|
|
AGENT_LISTEN_ADDR=:50051
|
|
AGENT_KERNEL_PATH=/var/lib/wrenn/kernels/vmlinux
|
|
AGENT_IMAGES_PATH=/var/lib/wrenn/images
|
|
AGENT_SANDBOXES_PATH=/var/lib/wrenn/sandboxes
|
|
AGENT_SNAPSHOTS_PATH=/var/lib/wrenn/snapshots
|
|
AGENT_HOST_INTERFACE=eth0
|
|
|
|
# Lago (billing — external service)
|
|
LAGO_API_URL=http://localhost:3000
|
|
LAGO_API_KEY=
|
|
|
|
# Object Storage (hibernate snapshots — Hetzner Object Storage, S3-compatible)
|
|
S3_BUCKET=wrenn-snapshots
|
|
S3_REGION=fsn1
|
|
S3_ENDPOINT=https://fsn1.your-objectstorage.com
|
|
AWS_ACCESS_KEY_ID=
|
|
AWS_SECRET_ACCESS_KEY=
|
|
|
|
# Auth
|
|
JWT_SECRET=
|
|
|
|
# OAuth
|
|
OAUTH_GITHUB_CLIENT_ID=
|
|
OAUTH_GITHUB_CLIENT_SECRET=
|
|
OAUTH_REDIRECT_URL=https://app.wrenn.dev
|
|
CP_PUBLIC_URL=https://api.wrenn.dev
|