ifixkart-admin/docs/authentication/google-oauth.md
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

1.7 KiB

Google OAuth 2.0 Integration Plan

Flow Architecture

sequenceDiagram
    autonumber
    actor Customer
    participant Frontend as Storefront Next.js
    participant Google as Google Identity Services
    participant Backend as FastAPI CustomerAuthRouter
    participant DB as MySQL DB

    Customer->>Frontend: Clicks "Continue with Google"
    Frontend->>Google: Triggers OAuth 2.0 Authorization Code Flow
    Google-->>Customer: Prompts Google Sign-In & Consent
    Customer->>Google: Authenticates
    Google-->>Frontend: Redirects with Authorization Code
    Frontend->>Backend: POST /api/v1/customer/auth/google { code }
    Backend->>Google: Exchanges Code for Google ID Token & Profile
    Google-->>Backend: Returns Verified Email, Google ID, Name, Picture
    Backend->>DB: Lookup EcomCustomer by google_id or email
    alt Customer Exists
        Backend->>DB: Link google_id if missing, update last_login
    else New Customer
        Backend->>DB: Create new EcomCustomer record
    end
    Backend-->>Frontend: Returns JWT Access Token + Refresh Token
    Frontend->>Frontend: Merges Anonymous Guest Cart & Wishlist to Customer Account

Security Verification Rules

  1. Authorization Code Exchange: Server-side exchange only (/oauth2/v4/token). Frontend never handles raw client secrets.
  2. Identity Verification: Verify Google ID Token signature against Google's public keys (https://www.googleapis.com/oauth2/v3/certs).
  3. Account Linking: If a customer registers via email user@example.com and later logs in via Google with user@example.com, safely link google_id to the existing account after verifying email_verified == true.