Add Google sign-in alongside emailed codes #1

Merged
neeldhara merged 9 commits from google-sign-in into main 2026-11-18 21:30:54 +05:30
Owner

Adds an optional "Continue with Google" button to /login, next to the existing one-time-code flow.

How it works

  • OpenID Connect authorization-code flow with PKCE, state and nonce; no new dependencies.
  • POST /api/auth/google/start checks the public origin, stores the flow state in a signed, HTTP-only, 10-minute cookie scoped to /api/auth/google, and redirects to Google.
  • GET /api/auth/google/callback checks the state, exchanges the code, validates the ID token claims (issuer, audience, expiry, nonce, verified email), then creates the usual session through recordLogin and setSessionCookie.
  • Only the openid email scopes are requested. No Google tokens or profile data are stored.
  • A verified Google address signs in to the same member account as a code emailed to that address, because accounts are keyed by email.
  • The "Remember me" choice and the next return path carry through the Google flow.

Configuration

The button stays hidden, and both routes refuse, unless these are set in Dokploy:

  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET

Authorised redirect URI to register in Google Cloud Console: https://gurusetu.com/api/auth/google/callback

Merging without those variables changes nothing visible on the live site.

Also changed

  • README.md and .env.example document the setup.
  • The privacy notice now mentions Google sign-in and carries today's date. Please read that wording before merging.

Testing

  • State cookie round trip, tamper rejection, PKCE challenge and ID-token claim checks were exercised against a mocked token endpoint.
  • Not yet tested against Google itself; that needs the OAuth client credentials.

🤖 Generated with Claude Code

https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj

Adds an optional "Continue with Google" button to `/login`, next to the existing one-time-code flow. ## How it works - OpenID Connect authorization-code flow with PKCE, state and nonce; no new dependencies. - `POST /api/auth/google/start` checks the public origin, stores the flow state in a signed, HTTP-only, 10-minute cookie scoped to `/api/auth/google`, and redirects to Google. - `GET /api/auth/google/callback` checks the state, exchanges the code, validates the ID token claims (issuer, audience, expiry, nonce, verified email), then creates the usual session through `recordLogin` and `setSessionCookie`. - Only the `openid email` scopes are requested. No Google tokens or profile data are stored. - A verified Google address signs in to the same member account as a code emailed to that address, because accounts are keyed by email. - The "Remember me" choice and the `next` return path carry through the Google flow. ## Configuration The button stays hidden, and both routes refuse, unless these are set in Dokploy: - `GOOGLE_CLIENT_ID` - `GOOGLE_CLIENT_SECRET` Authorised redirect URI to register in Google Cloud Console: `https://gurusetu.com/api/auth/google/callback` Merging without those variables changes nothing visible on the live site. ## Also changed - `README.md` and `.env.example` document the setup. - The privacy notice now mentions Google sign-in and carries today's date. Please read that wording before merging. ## Testing - State cookie round trip, tamper rejection, PKCE challenge and ID-token claim checks were exercised against a mocked token endpoint. - Not yet tested against Google itself; that needs the OAuth client credentials. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
Describe Google sign-in in the privacy notice
All checks were successful
Verify and deploy / Build and validate (pull_request) Successful in 5m8s
Verify and deploy / Deploy to Dokploy (pull_request) Has been skipped
8fbfa996f2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yR4PN5YbyxvArKFKSdkgj
neeldhara deleted branch google-sign-in 2026-11-18 21:30:55 +05:30
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Miscellany/gurusetu-platform!1
No description provided.