docs(docs): IDENTITY.md (routes, session, providers, MFA gap, manual validation); CLAUDE.md map + architecture; SUPABASE.md wiring; CHANGELOG; plan note; Step 7 verify contract
This commit is contained in:
1 parent
aa1985eead
commit
552733b4c8
6 files changed
+228
-8
No files matched your search
@@ -0,0 +1,57 @@
|
||||
# CONTRACT — step-07 identity, auth, /app shell (whole step, for the fresh verifier)
|
||||
- date: 2026-10-11 | flow: ad-hoc step (user brief) | branch: feature/step-07-identity-app-shell
|
||||
- status: active
|
||||
- spec: docs/development/IDENTITY.md; user brief (below)
|
||||
|
||||
## REQUEST (user brief 2026-10-11, condensed — IMMUTABLE)
|
||||
Implement Step 7 keeping the current visual identity (logo, palette, cream/white cards, terracotta buttons, desktop side navigation, mobile adaptation). Scope: (1) auth: email/password sign-in and sign-up, email verification, password recovery/reset, Google sign-in, Apple if clean, no phone; (2) guarded /app shell with desktop sidebar, mobile adaptation, light top bar, simple dashboard with useful cards and clean empty states, no fake modules; (3) Mon compte: personal info, professional info, preferences (incl. language), security, sign-out; (4) Supabase auth + profile integration, language synced with profiles.locale, platform roles per the foundations, MFA mandatory for admin roles if the foundations allow it, else document the gap. Constraints: existing local tool routes (home, new report, PDF import, editor) keep working unauthenticated; explicit coexistence; no unvalidated complex UI, no artificial stats, no rich admin screens, no change to the report engine.
|
||||
|
||||
## ACCEPTANCE CRITERIA
|
||||
1. Routes exist and are wired: /login /signup /forgot-password /reset-password /auth/callback /app /app/account.
|
||||
CHECK: grep -c "path=\"/login\"\|path=\"/signup\"\|path=\"/forgot-password\"\|path=\"/reset-password\"\|path=\"/auth/callback\"\|path=\"/app\"\|path=\"account\"" apps/app/src/app/App.tsx
|
||||
EXPECT: 7
|
||||
2. Local tool routes unchanged and unauthenticated: HomeRoute, NewReportRoute, EditorRoute are rendered outside RequireAuth; their characterisation tests pass.
|
||||
CHECK: grep -n "LocalToolShell\|RequireAuth" apps/app/src/app/App.tsx | head; cd apps/app && corepack pnpm vitest run tests/unit/routes.HomeRoute.import.test.tsx tests/unit/routes.HomeRoute.archive.test.tsx tests/unit/routes.EditorRoute.test.tsx tests/unit/routes.NewReportRoute.test.tsx 2>&1 | tail -2
|
||||
EXPECT: the three local routes are inside LocalToolShell (path "*"), not under the /app RequireAuth element ; passed
|
||||
3. Guard: /app/* requires a session, redirects to /login?next=<same-origin path>; `next` never accepts an absolute or protocol-relative URL.
|
||||
CHECK: cd apps/app && corepack pnpm vitest run tests/unit/guards.RequireAuth.test.tsx tests/unit/auth.validation.test.ts 2>&1 | tail -2; grep -n "startsWith('//')" apps/app/src/auth/redirects.ts
|
||||
EXPECT: passed ; one match
|
||||
4. Auth flows call the client with the right inputs: sign-in (email, password), sign-up (metadata display_name + locale, emailRedirectTo ending in /auth/callback), reset (redirectTo /reset-password), updateUser({password}), signOut, signInWithOAuth(provider, redirectTo /auth/callback).
|
||||
CHECK: grep -n "emailRedirectTo\|RESET_PASSWORD_PATH\|AUTH_CALLBACK_PATH" apps/app/src/app/routes/auth/*.tsx apps/app/src/components/auth/OAuthButtons.tsx | wc -l; cd apps/app && corepack pnpm vitest run tests/unit/routes.LoginRoute.test.tsx tests/unit/routes.SignupRoute.test.tsx tests/unit/routes.AccountRoute.test.tsx 2>&1 | tail -2
|
||||
EXPECT: >= 4 ; passed
|
||||
5. Server errors are never shown raw: every GoTrue error goes through classifyAuthError → AuthFailure kind → `auth.failure.<kind>` key present in fr and en for every kind of the union.
|
||||
CHECK: grep -o "| '[a-z_]*'" packages/supabase/src/auth.ts | sed "s/| '//;s/'//" | sort -u > /tmp/kinds.txt; for k in $(cat /tmp/kinds.txt); do grep -q "'auth.failure.$k'" apps/app/src/i18n/fr.ts && grep -q "'auth.failure.$k'" apps/app/src/i18n/en.ts || echo MISSING $k; done
|
||||
EXPECT: no MISSING line (12 kinds)
|
||||
6. Email verification mandatory and password policy mirrored: config.toml enable_confirmations = true, minimum_password_length = 12, password_requirements lower_upper_letters_digits; client passwordSchema min 12 + the three classes.
|
||||
CHECK: grep -n "enable_confirmations = true\|minimum_password_length = 12\|lower_upper_letters_digits" supabase/config.toml | wc -l; grep -n "PASSWORD_MIN_LENGTH = 12\|\[a-z\]\|\[A-Z\]\|\[0-9\]" apps/app/src/auth/validation.ts | wc -l
|
||||
EXPECT: 3 ; >= 4
|
||||
7. Google and Apple: config.toml sections read ids from env(), app shows buttons only for APP_AUTH_PROVIDERS / VITE_AUTH_PROVIDERS, entrypoint and DEPLOY.md carry the variable.
|
||||
CHECK: grep -n "\[auth.external.google\]\|\[auth.external.apple\]\|env(SUPABASE_AUTH_EXTERNAL" supabase/config.toml | wc -l; grep -n "APP_AUTH_PROVIDERS" docker/entrypoint.sh DEPLOY.md | wc -l; grep -n "resolveAuthProviders" apps/app/src/config/env.ts | wc -l
|
||||
EXPECT: 6 ; >= 2 ; >= 2
|
||||
8. Profile integration: own-row read + update through packages/supabase; professional columns exist with CHECKs and column grants; pgTAP 009 runs on PGlite and the real stack; database.types in sync.
|
||||
CHECK: cd packages/supabase && corepack pnpm vitest run 2>&1 | tail -2; grep -c "grant update (practice_name, professional_title, siret)" supabase/migrations/20261011100000_profiles_professional.sql; grep -c "practice_name" packages/supabase/src/database.types.ts
|
||||
EXPECT: passed ; 1 ; 3
|
||||
9. Language sync both ways: profile locale applied on sign-in, switch saved to profiles.locale while signed in, untouched when signed out.
|
||||
CHECK: cd apps/app && corepack pnpm vitest run tests/unit/services.localeSync.test.ts 2>&1 | tail -2
|
||||
EXPECT: passed (3 tests)
|
||||
10. Platform roles shown read-only (badges, `shell.role.*` for the four enum values), no grant/revoke UI.
|
||||
CHECK: grep -c "'shell.role\." apps/app/src/i18n/fr.ts; grep -rn "grant_platform_role\|revoke_platform_role" apps/app/src | wc -l
|
||||
EXPECT: 4 ; 0
|
||||
11. MFA: documented gap (IDENTITY.md §4) and server-side TOTP enabled; the Security section shows the note; no fake enrolment UI.
|
||||
CHECK: grep -n "enroll_enabled = true" supabase/config.toml | wc -l; grep -n "^## 4. MFA" docs/development/IDENTITY.md; grep -n "mfa_note" apps/app/src/components/account/SecurityPanel.tsx | wc -l
|
||||
EXPECT: 1 ; one heading ; 1
|
||||
12. Shell and responsive: desktop sidebar (lg:), mobile drawer behind a labelled button, no horizontal overflow risk patterns; tests pass.
|
||||
CHECK: cd apps/app && corepack pnpm vitest run tests/unit/shell.AppLayout.test.tsx tests/unit/routes.DashboardRoute.test.tsx 2>&1 | tail -2; grep -n "lg:hidden\|hidden lg:flex" apps/app/src/components/shell/AppLayout.tsx | wc -l
|
||||
EXPECT: passed ; >= 2
|
||||
13. Dashboard content is honest: no numeric statistic, no fake module; cards = profile completeness, local tool, account facts.
|
||||
CHECK: grep -n "ProfileCard\|ToolCard\|AccountCard" apps/app/src/app/routes/app/DashboardRoute.tsx | wc -l; grep -nE "[0-9]+ (bilans|reports|clients)" apps/app/src/i18n/fr.ts apps/app/src/i18n/en.ts | wc -l
|
||||
EXPECT: >= 6 ; 0
|
||||
14. i18n parity (fr/en same key set) and lint 0 warnings, typecheck clean, build OK.
|
||||
CHECK: cd apps/app && corepack pnpm vitest run tests/unit/i18n.dicts.test.ts 2>&1 | tail -2; cd ../.. && corepack pnpm typecheck 2>&1 | grep -c "error TS"; corepack pnpm lint 2>&1 | grep -c "✖"
|
||||
EXPECT: passed ; 0 ; 0
|
||||
15. Coexistence explicit: Home header shows the entry only when Supabase is configured (HomeSpaceLink returns null otherwise); /app dashboard links back to the local tool.
|
||||
CHECK: grep -n "if (!supabase) return null" apps/app/src/components/brand/HomeSpaceLink.tsx | wc -l; grep -n 'to="/new"\|to="/"' apps/app/src/app/routes/app/DashboardRoute.tsx | wc -l
|
||||
EXPECT: 1 ; 2
|
||||
16. Docs synced: IDENTITY.md exists with routes, session, config, MFA gap, manual validation; CLAUDE.md map + architecture mention the identity layer; CHANGELOG entry; plan note.
|
||||
CHECK: grep -c "^## " docs/development/IDENTITY.md; grep -n "authStore\|IDENTITY.md" CLAUDE.md | wc -l; grep -n "Identity (Step 7)" CHANGELOG.md | wc -l; grep -n "Step 7 implementation note" docs/development/IMPLEMENTATION_PLAN.md | wc -l
|
||||
EXPECT: 5 ; >= 2 ; 1 ; 1
|
||||
@@ -6,6 +6,10 @@ Versions follow [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added (SaaS migration, plan Step 7)
|
||||
|
||||
- **Identity (Step 7)** — sign-in and sign-up by email/password (confirmation mandatory, policy 12 chars + lower/upper/digit), password recovery, OAuth buttons (Google, Apple) driven by `APP_AUTH_PROVIDERS`, landing route for confirmation / OAuth links; the guarded `/app` shell (desktop sidebar, light top bar, mobile drawer) with a dashboard (greeting, profile completeness, local tool, account) and **Mon compte** (personal, professional, preferences, security). Profile columns `practice_name`, `professional_title`, `siret` (migration `20261011100000`, pgTAP 009), language synced with `profiles.locale`, platform roles shown read-only. GoTrue TOTP enabled server-side; MFA enforcement for platform roles documented as a gap (`docs/development/IDENTITY.md`). The local tool (`/`, `/new`, `/editor`) stays unauthenticated; the Home header links to the space only when Supabase is configured.
|
||||
|
||||
### Added (SaaS migration, plan Steps 3–6)
|
||||
|
||||
- **Autonomous PDF archives (Step 6)** — new `@faunosteo/pdf` engine (`packages/pdf`): the PDF is rendered from explicit inputs (report, sheet snapshot, branding, labels, locale, rasterizer, export date), with no network and no browser DOM; the attachment becomes a **report archive envelope v1** (`osteo-report.json`) carrying the Report v3, a lean but valid snapshot of the anatomical sheet (views, annotations, geometry, colours, relations, the finding paths used with their ancestor labels, the SVG drawing), the branding used at export and the FR/EN label dictionary, so an old bilan is reproduced identically after any catalog, wording or logo change. Layered reading keeps the report even when the wrapper or the snapshot is refused (closed reasons), v2 and bare v3 PDFs still import, a PDF whose attachment was stripped is recognised. Imported archives are kept in the session; a bilan reopened on a different sheet is rebased on a working copy with unresolved items flagged and their labels kept, and the import message says so. SVG assets go through an allowlist sanitiser with size and complexity caps checked at import and at export; a WinAnsi guard keeps any text from crashing the export. Pages unchanged (frozen by 39 goldens). `docs/PDF-FORMAT.md` written for real.
|
||||
|
||||
@@ -22,7 +22,12 @@ through a generated migration map. Step 6 made the PDF an autonomous archive: th
|
||||
labels, rasterizer) with no network and no DOM, and the attachment is an envelope v1
|
||||
carrying the report, a lean sheet snapshot, the branding and the labels used, so an old
|
||||
bilan is reproduced identically after any catalog, wording or logo change
|
||||
(`docs/PDF-FORMAT.md`). The Supabase client is still unused by the UI.
|
||||
(`docs/PDF-FORMAT.md`). Step 7 added identity: email/password sign-up with
|
||||
confirmation, password recovery, OAuth buttons driven by config, the guarded
|
||||
`/app` shell (dashboard, Mon compte with personal / professional / preferences /
|
||||
security sections) on Supabase Auth + `profiles` + `profile_roles`, language
|
||||
synced with `profiles.locale` (`docs/development/IDENTITY.md`). The local tool
|
||||
routes stay unauthenticated.
|
||||
MVP species: equine only. Open-source MIT.
|
||||
|
||||
---
|
||||
@@ -161,31 +166,41 @@ faunosteo/
|
||||
│ ├─ app/
|
||||
│ │ ├─ App.tsx ← root router
|
||||
│ │ ├─ routes/{Home,NewReport,Editor,NotFound}Route.tsx
|
||||
│ │ └─ providers/ConfigProvider.tsx ← AppConfig context
|
||||
│ │ ├─ routes/auth/{Login,Signup,ForgotPassword,ResetPassword,AuthCallback}Route.tsx
|
||||
│ │ ├─ routes/app/{Dashboard,Account}Route.tsx ← behind RequireAuth, inside AppLayout
|
||||
│ │ ├─ guards/{RequireAuth,RedirectIfSignedIn,SessionLoading}.tsx
|
||||
│ │ └─ providers/{ConfigProvider,AuthProvider}.tsx ← AppConfig context; session + locale sync start
|
||||
│ ├─ auth/{validation,redirects,useAuthFailureMessage}.ts ← Zod schemas (i18n keys), safe next path, failure phrasing
|
||||
│ ├─ account/{validation,useProfileForm}.ts ← account section schemas + one-save form hook
|
||||
│ ├─ config/env.ts ← runtime config resolution
|
||||
│ ├─ sheets/{provider,useSheet}.ts ← SheetProvider interface, bundled implementation, per-species hook
|
||||
│ ├─ services/
|
||||
│ │ ├─ sheetIndex.ts ← read-only lookups over the loaded sheet (ids, never labels)
|
||||
│ │ └─ zoneInteraction.ts ← pure click decision + observation reducers (zones, sides, vertebrae)
|
||||
│ │ ├─ zoneInteraction.ts ← pure click decision + observation reducers (zones, sides, vertebrae)
|
||||
│ │ └─ localeSync.ts ← profiles.locale ↔ localeStore (account wins on sign-in)
|
||||
│ ├─ i18n/
|
||||
│ │ ├─ types.ts ← Locale type + Dict type
|
||||
│ │ ├─ fr.ts + en.ts ← translation dicts (flat key → string)
|
||||
│ │ ├─ index.ts ← getDict(locale)
|
||||
│ │ └─ useT.ts ← useT() hook (reads localeStore)
|
||||
│ ├─ state/
|
||||
│ │ ├─ authStore.ts ← session, user, profile, roles, recovery flag (onAuthStateChange)
|
||||
│ │ ├─ reportStore.ts ← Zustand store (Report v3) + persistence.ts (sessionStorage adapter, v2 draft migration)
|
||||
│ │ ├─ localeStore.ts ← locale Zustand store (persisted to localStorage)
|
||||
│ │ └─ practitionerCache.ts ← localStorage prefill
|
||||
│ ├─ anatomy/drawing.ts ← sanitised asset + generated annotation layer → inline <svg> per view
|
||||
│ ├─ components/
|
||||
│ │ ├─ ui/{Button,Card,Dialog,Input,Label,Select,Textarea,Badge,Chip}.tsx
|
||||
│ │ ├─ ui/{Button,ButtonLink,Card,Dialog,Input,Label,Select,Textarea,Badge,Chip,Icon,FormField,Notice}.tsx
|
||||
│ │ ├─ canvas/{AnatomyCanvas,DetailModal}.tsx
|
||||
│ │ ├─ observation/{ObservationList,ObservationCard,ObservationPickers,FindingsTreePicker,
|
||||
│ │ │ VertebraPicker,SeveritySelector,LateralityPicker,
|
||||
│ │ │ FreeTextFindingInput}.tsx
|
||||
│ │ ├─ report/{ReportHeader,PractitionerForm,AnimalForm,EditInfosDialog,DisclaimerDialog,
|
||||
│ │ │ ConclusionPanel,NextAppointmentPicker}.tsx
|
||||
│ │ └─ brand/{Brand,AppHeader,Footer,LanguageSwitcher}.tsx
|
||||
│ │ ├─ brand/{Brand,AppHeader,Footer,LanguageSwitcher,HomeSpaceLink}.tsx
|
||||
│ │ ├─ auth/{AuthLayout,OAuthButtons,PasswordField,UnavailableNotice,AuthLink}.tsx
|
||||
│ │ ├─ shell/{AppLayout,SidebarNav,MobileDrawer,UserBadge,SignOutButton}.tsx
|
||||
│ │ └─ account/{SectionCard,SaveRow,PersonalInfoForm,ProfessionalInfoForm,PreferencesForm,SecurityPanel,RoleBadges}.tsx
|
||||
│ ├─ pdf/ ← app side of @faunosteo/pdf (engine in packages/pdf)
|
||||
│ │ ├─ export.ts + import.ts ← exportReportToPdf (sheet snapshot + branding + browser rasterizer → engine), importReportFromPdf (ArchiveReadOutcome, ImportError kinds)
|
||||
│ │ └─ branding.ts + browserRasterizer.ts ← bundled src/assets/brand logos (?inline / ?raw) → Branding; Image/canvas Rasterizer adapter
|
||||
@@ -275,6 +290,13 @@ PDF import
|
||||
→ rebaseReportOnSheet(report, index, archivedSnapshot) when the loaded sheet differs (unresolved flags, labels kept)
|
||||
→ hydrateImport({ report, archive }) → one alert (archive_ok / snapshot_rejected / rebased / migrated) → navigate /editor
|
||||
|
||||
Identity (Step 7, docs/development/IDENTITY.md)
|
||||
→ AuthProvider: authStore.start() = client.auth.initialize() (PKCE code in URL) + onAuthStateChange
|
||||
→ signed_in → fetchOwnProfile + fetchOwnPlatformRoles; localeSync applies profiles.locale, saves switches
|
||||
→ /login /signup /forgot-password /reset-password /auth/callback (packages/supabase auth wrappers, AuthFailure kinds)
|
||||
→ RequireAuth guards /app/* (→ /login?next=), AppLayout (sidebar / top bar / drawer), Dashboard, Account (updateOwnProfile)
|
||||
→ no Supabase configured: status unavailable, auth screens show a notice, local tool unchanged
|
||||
|
||||
Runtime config
|
||||
→ Docker entrypoint writes env.js (window.__APP_CONFIG__)
|
||||
→ index.html loads env.js before bundle
|
||||
@@ -304,7 +326,8 @@ Database (Supabase)
|
||||
- Key convention: `<area>.<key>` — e.g. `common.cancel`, `home.new_report.title`, `pdf.subject`
|
||||
- Both dicts must share the exact same key set; a key missing in one dict logs a warning in DEV
|
||||
- Get the translate function in any component: `const t = useT()` then `t('common.cancel')`
|
||||
- `src/state/localeStore.ts` holds current `Locale` (`'fr' | 'en'`), persisted to `localStorage` key `osteo:locale`; default: navigator-detected `fr`/`en`, or `'fr'` if no match
|
||||
- `src/state/localeStore.ts` holds current `Locale` (`'fr' | 'en'`), persisted to `localStorage` key `osteo:locale`; default: navigator-detected `fr`/`en`, or `'fr'` if no match; while signed in, `services/localeSync.ts` writes it to `profiles.locale` and applies the account locale on sign-in
|
||||
- Form validation messages are i18n keys returned by the Zod schemas (`src/auth/validation.ts`, `src/account/validation.ts`), translated next to the field; GoTrue messages never reach the screen (`auth.failure.*`)
|
||||
- Zone and finding names shown in the editor and the PDF come from the sheet document (`{ fr, en }` labels) and from the report's snapshots, not from the dict
|
||||
- PDF static labels (section headings, metadata) live in the engine (`packages/pdf/src/i18n`, `defaultPdfLabels`, 25 keys) and are archived in the envelope; the app dicts hold no `pdf.*` key
|
||||
|
||||
@@ -351,6 +374,7 @@ Database (Supabase)
|
||||
validated and a production build carries no sheet unless that flag is set on purpose
|
||||
|
||||
### Database (Supabase)
|
||||
- The auth session lives in the Supabase client (localStorage, PKCE); the app reads it through `state/authStore.ts` only. Profile columns the user may edit are the column grants in the profiles migrations; never widen them from the client.
|
||||
- Platform roles (`platform_role`: owner/admin/moderator/support) are NOT professional
|
||||
statuses (practitioner/student/professor come from verification, cabinet roles from
|
||||
organization_members). Never add a professional status to `platform_role`.
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
# Identity: auth, profile, /app shell (Step 7)
|
||||
|
||||
Source of truth for the signed-in space added in Step 7. The local tool
|
||||
(`/`, `/new`, `/editor`) is untouched and needs no account; the two live side
|
||||
by side until the plan's Step 14 decides what goes behind authentication.
|
||||
|
||||
## 1. Routes
|
||||
|
||||
| Route | Guard | Screen |
|
||||
|---|---|---|
|
||||
| `/login` | visitor only (`RedirectIfSignedIn`) | email + password, OAuth buttons per `authProviders`, link to signup / forgot |
|
||||
| `/signup` | visitor only | display name, email, password ×2 → "check your inbox" step |
|
||||
| `/forgot-password` | visitor only | email → "link sent" step |
|
||||
| `/reset-password` | none; needs the recovery session | new password ×2; "invalid or expired link" otherwise |
|
||||
| `/auth/callback` | none | landing of OAuth redirects and confirmation links; waits for the session then goes to `/app` (or `?next=`) |
|
||||
| `/app` | `RequireAuth` | dashboard: greeting, profile completeness card, local tool card, account card |
|
||||
| `/app/account` | `RequireAuth` | Mon compte: personal, professional, preferences (language, timezone), security (password, MFA note, sign out) |
|
||||
|
||||
`RequireAuth` waits for the client to read the persisted session, then sends
|
||||
a visitor to `/login?next=<path>`; `next` is honoured only when it is a
|
||||
same-origin path (`safeNextPath`). `/app/*` under the guard renders inside
|
||||
`AppLayout` (desktop sidebar, light top bar, mobile drawer).
|
||||
|
||||
A deployment without Supabase (`APP_SUPABASE_URL` empty) shows an
|
||||
"unavailable" notice on the auth screens; `/app` redirects to `/login`; the
|
||||
Home header shows no entry to the space. With Supabase configured, the Home
|
||||
header shows "Se connecter" or "Mon espace".
|
||||
|
||||
## 2. Session and profile in the app
|
||||
|
||||
- `state/authStore.ts` subscribes to `client.auth.onAuthStateChange` after
|
||||
`client.auth.initialize()` (which also exchanges the PKCE code found in the
|
||||
URL). Status: `loading | unavailable | signed_out | signed_in`. On sign-in it
|
||||
loads `profiles` (own row) and the active `profile_roles`.
|
||||
- `services/localeSync.ts`: when a profile loads, its `locale` wins over the
|
||||
device choice (once per sign-in); while signed in, switching the language
|
||||
(header toggle or the Preferences select) writes `profiles.locale`.
|
||||
- Profile writes go through `updateOwnProfile` (`packages/supabase`), one
|
||||
PATCH per account section; the columns are the ones the migrations grant
|
||||
(`display_name, first_name, last_name, phone, locale, timezone,
|
||||
practice_name, professional_title, siret`). `active`,
|
||||
`phone_verified_at` and roles are server-only.
|
||||
- Platform roles are read-only badges (`shell.role.*`); no admin screen yet.
|
||||
- GoTrue errors never reach the screen: `classifyAuthError` folds codes into a
|
||||
closed `AuthFailureKind`, phrased by `auth.failure.*`.
|
||||
|
||||
## 3. Server configuration
|
||||
|
||||
`supabase/config.toml`:
|
||||
|
||||
- email/password with confirmation mandatory, password policy 12 chars +
|
||||
lower/upper/digit (mirrored client-side in `src/auth/validation.ts`);
|
||||
- `[auth.external.google]` / `[auth.external.apple]` read their ids from
|
||||
`env(SUPABASE_AUTH_EXTERNAL_<PROVIDER>_CLIENT_ID|SECRET)`; both are
|
||||
`enabled = false` until the ids exist (put them in `supabase/.env`, gitignored,
|
||||
then flip `enabled`). Google needs an OAuth client with the redirect
|
||||
`http://127.0.0.1:54321/auth/v1/callback` (local) or
|
||||
`https://<project>.supabase.co/auth/v1/callback`; Apple needs a paid developer
|
||||
account and a Services ID (BACKEND_ARCHITECTURE §2);
|
||||
- `[auth.mfa.totp]` enrolment and verification are on server-side;
|
||||
- redirect URLs allow `http://127.0.0.1:5173/**` and `http://localhost:5173/**`.
|
||||
|
||||
The app side: `APP_AUTH_PROVIDERS=google,apple` (Docker) or
|
||||
`VITE_AUTH_PROVIDERS` (dev) lists the buttons to show. Showing a button for a
|
||||
provider the server has not enabled yields the phrased error
|
||||
"this sign-in method is not enabled".
|
||||
|
||||
PKCE pitfall: a confirmation or recovery link must be opened in the browser
|
||||
that made the request (the code verifier lives in its localStorage). Opened
|
||||
elsewhere, the email is still confirmed server-side but no session opens; the
|
||||
callback page says so and the user signs in normally.
|
||||
|
||||
## 4. MFA: what the foundations have, what is missing
|
||||
|
||||
Architecture §2 wants TOTP mandatory for `owner/admin/moderator/support`,
|
||||
enforced by an RLS helper `has_mfa()` on admin tables. Today:
|
||||
|
||||
- server: TOTP enrolment/verification enabled (this step); nothing enforces it;
|
||||
- SQL: no `private.has_mfa()` helper (would read `auth.jwt() ->> 'aal' = 'aal2'`);
|
||||
the role helpers `private.is_platform_*` ignore the assurance level;
|
||||
- app: no enrolment UI (QR + code), no `aal2` step-up on sign-in;
|
||||
- there is no admin table or screen yet to protect.
|
||||
|
||||
The Security section shows a note instead. To close the gap (a later step):
|
||||
migration adding `private.has_mfa()` and folding it into `is_platform_*` (or
|
||||
into the policies of the first admin table) with pgTAP allowed/denied cases;
|
||||
enrolment + challenge screens in Mon compte; step-up at sign-in for accounts
|
||||
holding a platform role.
|
||||
|
||||
## 5. Manual validation (local stack)
|
||||
|
||||
```bash
|
||||
pnpm db:start # prints API URL + anon key; Mailpit at http://127.0.0.1:54324
|
||||
VITE_SUPABASE_URL=http://127.0.0.1:54321 VITE_SUPABASE_ANON_KEY=<anon key> \
|
||||
VITE_AUTH_PROVIDERS=google pnpm dev
|
||||
```
|
||||
|
||||
1. `/app` while signed out → `/login?next=%2Fapp`. The login card shows a
|
||||
Google button (not functional until the provider is enabled: expect the
|
||||
"not enabled" message).
|
||||
2. Wrong password → "E-mail ou mot de passe incorrect". Seeded account
|
||||
`alice@faunosteo.local` / `LocalDev-only-password-1` → lands on `/app`.
|
||||
3. Dashboard: greeting, "À compléter : Prénom, Nom", "Adresse confirmée",
|
||||
no platform role (owner@ shows "Propriétaire plateforme").
|
||||
4. Mon compte: fill professional title / practice / SIRET → "Modifications
|
||||
enregistrées"; SIRET `1234` → inline error, nothing saved. Language select
|
||||
or the FR/EN toggle → the UI switches; reload → the account language is
|
||||
applied (profiles.locale in Studio).
|
||||
5. Mobile (375 px): hamburger opens the drawer; navigation closes it; no
|
||||
horizontal scroll on login, dashboard, account.
|
||||
6. Home shows "Mon espace" while signed in; sidebar "Se déconnecter" → Home with
|
||||
"Se connecter"; `/app` guarded again.
|
||||
7. `/signup` with a new address → "Vérifiez votre boîte mail"; open Mailpit,
|
||||
click the confirmation link in the same browser → `/app` signed in,
|
||||
"Adresse confirmée".
|
||||
8. `/forgot-password` → Mailpit recovery link → `/reset-password` → new
|
||||
password → `/app`; sign out and sign in with the new password.
|
||||
9. REST: anon cannot read profiles (`42501`), alice reads one row only
|
||||
(SUPABASE.md §8).
|
||||
|
||||
Automated: `pnpm test:run` (auth store, locale sync, forms, guards, shell,
|
||||
dashboard, account, pgTAP 009), plus the headless end-to-end run described in
|
||||
the Step 7 report (not part of CI).
|
||||
@@ -216,6 +216,13 @@ Definition of Done: architecture Sprint 1 identity part; audit_logs receives rol
|
||||
Risks: Apple sign-in setup cost; phone provider pending (Q7).
|
||||
```
|
||||
|
||||
Step 7 implementation note (2026-10-11): shipped as `docs/development/IDENTITY.md`.
|
||||
Deviations: no TanStack Query (a zustand store covers the profile read/update of this
|
||||
step; the query layer comes with the first list screens); `platform_invitations` and the
|
||||
MFA helper not written (no admin screen to protect yet, gap documented in IDENTITY.md §4);
|
||||
professional fields added to `profiles` as declared free text (verification = Step 11);
|
||||
Google/Apple wired in config.toml behind env ids, buttons behind `APP_AUTH_PROVIDERS`.
|
||||
|
||||
```text
|
||||
Step 8
|
||||
Name: Files foundation (Storage)
|
||||
|
||||
@@ -233,8 +233,13 @@ APP_SUPABASE_URL=http://127.0.0.1:54321 # VITE_SUPABASE_URL in dev
|
||||
APP_SUPABASE_ANON_KEY=<anon key> # VITE_SUPABASE_ANON_KEY in dev
|
||||
```
|
||||
|
||||
Both empty (the default) keeps the app in its current local-only mode:
|
||||
`getSupabaseClient()` returns null. No screen uses the client yet.
|
||||
Both empty (the default) keeps the app in its local-only mode:
|
||||
`getSupabaseClient()` returns null, the auth screens show an "unavailable"
|
||||
notice and `/app` redirects to `/login`. `APP_AUTH_PROVIDERS` /
|
||||
`VITE_AUTH_PROVIDERS` (`google,apple`) lists the OAuth buttons to show.
|
||||
Sign-in, sign-up, email confirmation, password recovery, the `/app` shell
|
||||
and Mon compte are documented in `IDENTITY.md` (routes, session handling,
|
||||
provider setup, MFA gap, manual validation).
|
||||
|
||||
## 10. Self-hosted parity
|
||||
|
||||
|
||||
Reference in new issue
Block a user