Backend
- @adonisjs/ally installé + provider Google configuré (config/ally.ts)
scopes: userinfo.email + userinfo.profile (non-sensibles, validation
auto par Google)
- Migration : ajoute google_id (nullable unique) sur users + rend password
nullable (un user créé via Google n'a pas de mdp en base, il pourra
l'activer plus tard via "mot de passe oublié")
- AuthGoogleController.redirect : entrée OAuth (le bouton SPA pointe ici)
- AuthGoogleController.callback : matche par google_id puis email,
crée org+plans+user si nouveau, pose le refresh cookie httpOnly,
redirige le browser vers le SPA /auth/google/complete?next=...
(next = / pour user complet, /onboarding/entreprise pour nouveau)
- Routes : GET /api/v1/auth/google/{redirect,callback}
- Env : GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_CALLBACK_URL
Frontend
- Composant GoogleButton réutilisable (full-page redirect, pas fetch —
OAuth nécessite navigation pour les cookies cross-origin Google)
- AuthDivider "ou" entre SSO et formulaire email/password
- Boutons ajoutés sur /login et /signup
- Route /auth/google/complete : appelle POST /api/v1/auth/refresh (le
cookie posé par la callback est auto-envoyé), stocke access token +
user dans authStore, navigue vers `next`. Échec → /login + toast.
- Toast d'erreur sur /login si on revient avec ?google=denied|error|...
K3s
- ConfigMap rubis-api-config : ajout GOOGLE_CALLBACK_URL prod
- Secret rubis-app-secrets : ajout GOOGLE_CLIENT_ID + GOOGLE_CLIENT_SECRET
(posés via kubectl, pas dans le manifest)
Doc
- .claude/deploy-memory.md mis à jour avec la procédure Google Cloud
Console (créer OAuth client, redirect URIs, écran de consentement)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
138 lines
3.9 KiB
YAML
138 lines
3.9 KiB
YAML
# Rubis API — AdonisJS V7 (Node 22). ClusterIP uniquement, accessible
|
|
# depuis nginx (rubis-web) via DNS K3s : rubis-api.rubis.svc.cluster.local
|
|
# Workers BullMQ tournent dans le même process (cf. start/queue.ts).
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: rubis-api
|
|
namespace: rubis
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxSurge: 1
|
|
maxUnavailable: 0
|
|
selector:
|
|
matchLabels:
|
|
app: rubis-api
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: rubis-api
|
|
spec:
|
|
imagePullSecrets:
|
|
- name: gitea-registry
|
|
# Migrations : exécutées en init-container avant que le serveur démarre.
|
|
# Idempotent (ace migration:run skip ce qui est déjà appliqué).
|
|
# workingDir = build/ pour utiliser ace.js compilé (les .ts ne se chargent
|
|
# pas en runtime, devDeps absentes).
|
|
initContainers:
|
|
- name: migrate
|
|
image: git.arthurbarre.fr/ordinarthur/rubis-api:latest
|
|
imagePullPolicy: Always
|
|
workingDir: /app/apps/api/build
|
|
command: ['node', 'ace.js', 'migration:run', '--force']
|
|
envFrom:
|
|
- secretRef: { name: rubis-app-secrets }
|
|
- configMapRef: { name: rubis-api-config }
|
|
resources:
|
|
requests: { cpu: 50m, memory: 128Mi }
|
|
limits: { cpu: 500m, memory: 512Mi }
|
|
containers:
|
|
- name: api
|
|
image: git.arthurbarre.fr/ordinarthur/rubis-api:latest
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- containerPort: 3333
|
|
name: http
|
|
envFrom:
|
|
- secretRef: { name: rubis-app-secrets }
|
|
- configMapRef: { name: rubis-api-config }
|
|
resources:
|
|
requests:
|
|
cpu: 100m
|
|
memory: 256Mi
|
|
limits:
|
|
cpu: 1000m
|
|
memory: 768Mi
|
|
startupProbe:
|
|
httpGet: { path: /api/v1/health, port: http }
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 5
|
|
failureThreshold: 30
|
|
livenessProbe:
|
|
httpGet: { path: /api/v1/health, port: http }
|
|
periodSeconds: 30
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
httpGet: { path: /api/v1/health, port: http }
|
|
periodSeconds: 10
|
|
timeoutSeconds: 3
|
|
failureThreshold: 3
|
|
---
|
|
# ClusterIP — accessible uniquement depuis le cluster (par nginx rubis-web).
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: rubis-api
|
|
namespace: rubis
|
|
spec:
|
|
type: ClusterIP
|
|
selector:
|
|
app: rubis-api
|
|
ports:
|
|
- port: 3333
|
|
targetPort: http
|
|
name: http
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: rubis-api-config
|
|
namespace: rubis
|
|
data:
|
|
# Variables non-sensibles. Les secrets sont dans rubis-app-secrets.
|
|
TZ: 'Europe/Paris'
|
|
PORT: '3333'
|
|
HOST: '0.0.0.0'
|
|
NODE_ENV: 'production'
|
|
LOG_LEVEL: 'info'
|
|
APP_URL: 'https://app.rubis.arthurbarre.fr'
|
|
WEB_URL: 'https://app.rubis.arthurbarre.fr'
|
|
SESSION_DRIVER: 'cookie'
|
|
COOKIE_SECURE: 'true'
|
|
COOKIE_DOMAIN: 'app.rubis.arthurbarre.fr'
|
|
|
|
DB_CONNECTION: 'postgres'
|
|
PG_HOST: '10.10.10.3'
|
|
PG_PORT: '5432'
|
|
PG_USER: 'rubis'
|
|
PG_DB_NAME: 'rubis_prod'
|
|
|
|
REDIS_HOST: 'rubis-redis.rubis.svc.cluster.local'
|
|
REDIS_PORT: '6379'
|
|
LIMITER_STORE: 'redis'
|
|
|
|
DRIVE_DISK: 's3'
|
|
S3_ENDPOINT: 'http://minio.minio.svc.cluster.local:9000'
|
|
S3_REGION: 'fr-par'
|
|
S3_BUCKET: 'rubis-prod-invoices'
|
|
S3_FORCE_PATH_STYLE: 'true'
|
|
|
|
MAIL_DRIVER: 'resend'
|
|
MAIL_FROM_ADDRESS: 'rubis@arthurbarre.fr'
|
|
MAIL_FROM_NAME: "Rubis Sur l'Ongle"
|
|
|
|
OCR_PROVIDER: 'mistral'
|
|
|
|
ACCESS_TOKEN_TTL_MINUTES: '30'
|
|
REFRESH_TOKEN_TTL_DAYS: '30'
|
|
|
|
# Google SSO — GOOGLE_CLIENT_ID/SECRET sont dans rubis-app-secrets.
|
|
# Le callback URL doit matcher EXACTEMENT ce qui est configuré dans
|
|
# Google Cloud Console (OAuth Client → Authorized redirect URIs).
|
|
GOOGLE_CALLBACK_URL: 'https://app.rubis.arthurbarre.fr/api/v1/auth/google/callback'
|