fiftyyears-auth
v0.1.0
Published
Drop-in Google login gate for fiftyyears apps. One shared OAuth client, minimal per-app setup.
Readme
fiftyyears-auth
Drop-in Google login gate for fiftyyears apps. One shared Google OAuth client across every app — minimal per-app setup, no new OAuth client per app.
One-time (once, ever)
Google Cloud Console → create one OAuth 2.0 Client (Web application):
- Consent screen: External, scopes
openid email profile. - You'll add each app's callback URL to this one client's Authorized redirect URIs (Google has no API for this — Console only).
Keep the Client ID + Secret; every app reuses them.
Per app
- Add env vars in Vercel:
GOOGLE_CLIENT_ID=<shared> GOOGLE_CLIENT_SECRET=<shared> AUTH_SESSION_SECRET=<32+ random chars, unique per app> AUTH_BASE_URL=https://<this-app>.vercel.app [email protected] # optional; empty = any Google account - Add this app's callback to the shared OAuth client's redirect URIs:
https://<this-app>.vercel.app/api/auth/callback npm install fiftyyears-auth- Four API routes (one line each):
// api/auth/login.ts export { loginHandler as default } from "fiftyyears-auth/server" // api/auth/callback.ts export { callbackHandler as default } from "fiftyyears-auth/server" // api/auth/logout.ts export { logoutHandler as default } from "fiftyyears-auth/server" // api/auth/me.ts export { meHandler as default } from "fiftyyears-auth/server" - Wrap the app:
import { AuthGate } from "fiftyyears-auth" <AuthGate appName="My App"><App /></AuthGate> - Gate any API route:
import { requireAuth } from "fiftyyears-auth/server" export default requireAuth(async (req, res, user) => { /* user is signed in */ })
Notes
- Session is a signed httpOnly cookie (7-day), HS256 over
AUTH_SESSION_SECRET. - Google's ID token is verified against Google's JWKS (issuer + audience checked).
useAuth()gives{ user, loading, logout }inside the gate.- The only recurring manual step per app is #2 (add one redirect URI) — Google exposes no API for it.
