|
| 1 | +# PR_26166_156-live-sign-in-and-provisioning |
| 2 | + |
| 3 | +## Branch Validation |
| 4 | + |
| 5 | +- Current branch: main |
| 6 | +- Expected branch: main |
| 7 | +- Branch validation: PASS |
| 8 | + |
| 9 | +## Summary |
| 10 | + |
| 11 | +Made Supabase Create Account and Sign In usable end-to-end through backend API contracts. |
| 12 | + |
| 13 | +- Create Account now uses server-owned Supabase Admin Auth user creation, provisions the matching `users` identity record, and assigns the default `user` role through `user_roles`. |
| 14 | +- Sign In authenticates with Supabase Auth, resolves the matching app identity rows, and creates the current session state. |
| 15 | +- Password Reset remains Supabase Auth provider-backed. |
| 16 | +- Missing identity records now fail visibly with: `Account identity setup is incomplete. Please contact support.` |
| 17 | +- Product data remains on Local DB with `GAMEFOUNDRY_DB_PROVIDER=local-db`. |
| 18 | + |
| 19 | +## Requirement Checklist |
| 20 | + |
| 21 | +- PASS - Main branch only; execution was on `main`. |
| 22 | +- PASS - `docs_build/dev/PROJECT_INSTRUCTIONS.md` was read before implementation. |
| 23 | +- PASS - Product data remains Local DB; no product-table migration was added. |
| 24 | +- PASS - Backend API contracts remain the browser boundary; browser tests call pages/API, not provider-specific browser logic. |
| 25 | +- PASS - Create Account creates a Supabase Auth user through server-side Admin Auth. |
| 26 | +- PASS - Create Account provisions the matching `users` record server-side. |
| 27 | +- PASS - Create Account assigns the default role through `user_roles`. |
| 28 | +- PASS - Sign In authenticates with Supabase Auth. |
| 29 | +- PASS - Sign In resolves `users`, `roles`, and `user_roles`. |
| 30 | +- PASS - Sign In creates and returns current session state. |
| 31 | +- PASS - Password Reset remains Supabase Auth provider-backed. |
| 32 | +- PASS - Missing identity records fail visibly and actionably. |
| 33 | +- PASS - No password tables were added. |
| 34 | +- PASS - No secrets or `.env.local` files were committed. |
| 35 | +- PASS - No silent fallback to Local DB auth was added. |
| 36 | + |
| 37 | +## Changed Files |
| 38 | + |
| 39 | +- `src/dev-runtime/auth/provider-contract-stubs.mjs` |
| 40 | +- `src/dev-runtime/server/local-api-router.mjs` |
| 41 | +- `tests/dev-runtime/SupabaseProviderContractStub.test.mjs` |
| 42 | +- `tests/playwright/tools/LoginSessionMode.spec.mjs` |
| 43 | +- `docs_build/dev/reports/codex_review.diff` |
| 44 | +- `docs_build/dev/reports/codex_changed_files.txt` |
| 45 | +- `docs_build/dev/reports/coverage_changed_js_guardrail.txt` |
| 46 | +- `docs_build/dev/reports/playwright_v8_coverage_report.txt` |
| 47 | +- `docs_build/dev/reports/PR_26166_156-live-sign-in-and-provisioning.md` |
| 48 | + |
| 49 | +## Impacted Lanes |
| 50 | + |
| 51 | +- runtime: auth provider/server API routing. |
| 52 | +- integration: Supabase identity table readiness and app session resolution. |
| 53 | +- Playwright impacted: Yes. |
| 54 | + |
| 55 | +## Validation Performed |
| 56 | + |
| 57 | +- PASS - `node --check src/dev-runtime/auth/provider-contract-stubs.mjs` |
| 58 | +- PASS - `node --check src/dev-runtime/server/local-api-router.mjs` |
| 59 | +- PASS - `node --check tests/dev-runtime/SupabaseProviderContractStub.test.mjs` |
| 60 | +- PASS - `node --check tests/playwright/tools/LoginSessionMode.spec.mjs` |
| 61 | +- PASS - `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs` |
| 62 | + - Result: 26 passed, 0 failed. |
| 63 | +- PASS - `npm run validate:supabase-dev` |
| 64 | + - Overall Result: PASS. |
| 65 | + - Users, roles, and user_roles REST/API table checks: PASS. |
| 66 | + - Direct DB connection: WARN only, due to `SELF_SIGNED_CERT_IN_CHAIN`; REST/API identity readiness passed. |
| 67 | +- PASS - `npx playwright test tests/playwright/tools/LoginSessionMode.spec.mjs --grep "Sign-in page uses a production-safe account form without public Local DB controls" --reporter=list` |
| 68 | + - Result: 1 passed. |
| 69 | +- PASS - `npx playwright test tests/playwright/tools/LoginSessionMode.spec.mjs --grep "Configured account auth actions use external Auth and resolve the app session" --reporter=list` |
| 70 | + - Result: 1 passed. |
| 71 | +- PASS - Live DEV API probe for create account, sign in, and session resolution. |
| 72 | +- PASS - Live DEV API probe for missing identity failure. |
| 73 | +- PASS - Live DEV API probe for password reset. |
| 74 | +- PASS - `git diff --check` |
| 75 | + |
| 76 | +## Live DEV Evidence |
| 77 | + |
| 78 | +`npm run validate:supabase-dev`: |
| 79 | + |
| 80 | +```text |
| 81 | +PASS - .env.local loaded (6 key(s) loaded) |
| 82 | +PASS - URL configured |
| 83 | +PASS - Publishable key configured |
| 84 | +PASS - Service role key configured |
| 85 | +PASS - Database URL configured |
| 86 | +PASS - Supabase reachable |
| 87 | +PASS - TLS validation |
| 88 | +PASS - Auth endpoint reachable |
| 89 | +PASS - Service role authentication |
| 90 | +WARN - Database connection (SELF_SIGNED_CERT_IN_CHAIN; REST/API identity readiness passed, so direct PostgreSQL TLS failure is advisory for DEV.) |
| 91 | +PASS - users table |
| 92 | +PASS - roles table |
| 93 | +PASS - user_roles table |
| 94 | +Overall Result: PASS |
| 95 | +``` |
| 96 | + |
| 97 | +Create Account and Sign In live probe: |
| 98 | + |
| 99 | +```json |
| 100 | +{ |
| 101 | + "createStatus": 200, |
| 102 | + "identityProvisioned": true, |
| 103 | + "signInStatus": 200, |
| 104 | + "sessionResolved": true, |
| 105 | + "currentSession": { |
| 106 | + "status": 200, |
| 107 | + "authenticated": true, |
| 108 | + "roleSlugs": ["user"], |
| 109 | + "userKeyLooksLikeUlid": true |
| 110 | + } |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +Missing identity live probe: |
| 115 | + |
| 116 | +```json |
| 117 | +{ |
| 118 | + "authOnlyCreated": true, |
| 119 | + "signInStatus": 503, |
| 120 | + "error": "Account identity setup is incomplete. Please contact support.", |
| 121 | + "messageIsActionable": true |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +Password Reset live probe: |
| 126 | + |
| 127 | +```json |
| 128 | +{ |
| 129 | + "passwordResetStatus": 200, |
| 130 | + "action": "password-reset", |
| 131 | + "redirectToIncluded": true, |
| 132 | + "message": "If an account exists for that email, password reset instructions will be sent." |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +## V8 Coverage |
| 137 | + |
| 138 | +- Coverage artifact: `docs_build/dev/reports/playwright_v8_coverage_report.txt` |
| 139 | +- Coverage status: WARN advisory for changed Node/server runtime modules because Chromium V8 coverage does not collect those files. |
| 140 | +- Browser auth scripts were exercised by the targeted Playwright runs. |
| 141 | + |
| 142 | +## Skipped Lanes |
| 143 | + |
| 144 | +- samples: SKIP - full samples smoke was explicitly out of scope. |
| 145 | +- product table migration: SKIP - product data remains Local DB by requirement. |
| 146 | +- full workspace suite: SKIP - targeted auth/session validation was the requested lane for this PR. |
| 147 | + |
| 148 | +## Manual Validation Notes |
| 149 | + |
| 150 | +1. Start the dev runtime with Supabase auth environment configured and `GAMEFOUNDRY_DB_PROVIDER=local-db`. |
| 151 | +2. Open `account/create-account.html`. |
| 152 | +3. Create a new account with an email and password. |
| 153 | +4. Open `account/sign-in.html` and sign in with that account. |
| 154 | +5. Confirm the session resolves with a `user` role. |
| 155 | +6. Open `account/password-reset.html` and request reset instructions. |
| 156 | +7. Confirm no browser-visible secrets are shown and failures use production-safe messages. |
0 commit comments