A lightweight authentication api with Google OAuth integration using OpenAuth.
- Bun 1.2.18 or later
- PostgreSQL database
- Cloudflare Workers account
- Google Cloud Platform account
- Clone the repository
git clone https://github.com/yopem/auth.git
cd auth- Install dependencies
bun install-
Google Auth Setup:
- Create OAuth 2.0 credentials in Google Cloud Platform
- Configure the authorized redirect URI:
https://your-domain/google/callback - Fill the
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETin your.dev.varsfile
-
Cloudflare Workers Setup:
- Create a KV database in Cloudflare Workers dashboard
- Rename
wrangler.jsonc.exampletowrangler.jsonc - Fill in all required fields using the Wrangler CLI for managing secrets, refer to the Cloudflare Workers Secrets documentation for more details.
-
Environment Variables:
- Add DATABASE_URL to your .env file because drizzle cannot read .dev.vars
-
Databse Migration:
bun run db:generate bun run db:migrate
bun run devbun run deploy