Backend
- Custom Ally driver Microsoft (Oauth2Driver) — Microsoft n'est pas dans
les providers built-in, mais le driver dérive de Oauth2Driver en quelques
lignes. Endpoints v2.0 (Microsoft Identity Platform), Graph /me pour le
profil, fallback userPrincipalName si mail null (comptes perso).
- Tenant configurable via MICROSOFT_TENANT (défaut 'common' — accepte
work/school + perso ; 'organizations' pour M365 strict).
- Migration 1400 : ajout microsoft_id nullable unique sur users.
- AuthMicrosoftController : redirect + callback (même pattern que Google).
- Refacto : extraction d'un service sso_session.ts (findOrCreateUserFromSso,
nextRouteAfterSso, emitSsoSessionAndRedirect) → AuthGoogle + AuthMicrosoft
partagent la logique.
- Routes /api/v1/auth/microsoft/{redirect,callback}.
Frontend
- Composant SsoButton générique (provider="google"|"microsoft") avec logo
officiel inline pour chaque. Remplace l'ancien GoogleButton.
- Login + signup : pile verticale "Continuer avec Google" + "Continuer
avec Microsoft", puis séparateur "ou", puis form email/password.
- Route SPA renommée /auth/google/complete → /auth/sso/complete (partagée
entre les deux providers, la callback API redirige toujours dessus).
- Erreurs SSO sur /login : ?google=... ET ?microsoft=... → toast contextuel.
K3s
- ConfigMap rubis-api-config : ajout MICROSOFT_TENANT + MICROSOFT_CALLBACK_URL.
- Secret rubis-app-secrets : ajout MICROSOFT_CLIENT_ID + MICROSOFT_CLIENT_SECRET.
Doc
- .claude/deploy-memory.md : procédure Azure / Entra ID app registration.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
145 lines
4.3 KiB
YAML
145 lines
4.3 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'
|
|
|
|
# Microsoft SSO — MICROSOFT_CLIENT_ID/SECRET sont dans rubis-app-secrets.
|
|
# MICROSOFT_TENANT : 'common' (work + perso), 'organizations' (M365 only),
|
|
# ou un tenant ID Azure AD spécifique. Le callback URL doit matcher
|
|
# EXACTEMENT le redirect URI configuré côté Azure App registration.
|
|
MICROSOFT_TENANT: 'common'
|
|
MICROSOFT_CALLBACK_URL: 'https://app.rubis.arthurbarre.fr/api/v1/auth/microsoft/callback'
|