- 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
1.7 KiB
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
- Authorization Code Exchange: Server-side exchange only (
/oauth2/v4/token). Frontend never handles raw client secrets. - Identity Verification: Verify Google ID Token signature against Google's public keys (
https://www.googleapis.com/oauth2/v3/certs). - Account Linking: If a customer registers via email
user@example.comand later logs in via Google withuser@example.com, safely linkgoogle_idto the existing account after verifyingemail_verified == true.