Skip to content

feat(auth): social sign-in server core — Supabase + wallet account-linking (part 1)#152

Merged
sacha-l merged 1 commit into
developfrom
feat/social-signin
May 22, 2026
Merged

feat(auth): social sign-in server core — Supabase + wallet account-linking (part 1)#152
sacha-l merged 1 commit into
developfrom
feat/social-signin

Conversation

@sacha-l
Copy link
Copy Markdown
Collaborator

@sacha-l sacha-l commented May 22, 2026

Summary

Server foundation for Google / Apple / passkey sign-in (via Supabase Auth) alongside the existing wallet (SIWS) auth. The wallet stays the authorization principal via account-linking, so the entire admin/builder authz layer is unchanged.

This is part 1 (server). The client UI is the next slice on this branch (see "Next").

How it works

  • A Supabase Auth user is linked to a wallet. Social sign-in then resolves to that wallet and issues the existing HMAC session bearer — so requireAdmin / requireProgramAdmin / team checks all authorize unchanged.
  • Supabase tokens are verified via supabase.auth.getUser(token) (no local JWT secret).

Server changes

  • Migration auth_identity_links (supabase_user_id ↔ wallet).
  • auth/supabaseUser.js — verify a Supabase access token (x-supabase-token header).
  • identity-link repository + service (best-effort mirror of email into wallet_contacts).
  • auth.controller + /api/auth routes:
    • POST /api/auth/link-wallet — requires a valid Supabase session and a SIWS signature; records the link; returns a wallet-scoped session bearer.
    • POST /api/auth/session-from-social — Supabase session → linked wallet → session bearer (409 needsLink if not linked yet).
  • CORS allows x-supabase-token.

Test plan

  • node --check server.js — OK.
  • npm test (server) — 271 passed (7 new auth-controller tests: invalid session, missing/failed SIWS, successful link, needs-link, session issue).

⚠️ Prerequisites (only you can do these — required before the client works)

  1. Supabase dashboard → Authentication → Providers: enable Google + Apple; enable Passkeys/WebAuthn. Set redirect URLs (stadium.joinwebzero.com, Vercel previews, localhost).
  2. Google Cloud: OAuth 2.0 client (web) → client ID/secret into Supabase.
  3. Apple: Sign in with Apple Service ID + key → into Supabase.
  4. Env: client VITE_SUPABASE_URL + VITE_SUPABASE_ANON_KEY (Vercel). Server already has SUPABASE_URL.

Next (client, this branch)

@supabase/supabase-js client + Google/Apple/passkey buttons + the OAuth-return → session-from-social → (first time) connect-wallet link-wallet flow, wired into the admin sign-in. Best built against the configured providers so it's testable end-to-end.

Per CLAUDE.md §6: draft, never merging.

…ount-linking

Adds Google/Apple/passkey sign-in (via Supabase Auth) alongside wallet SIWS,
keeping the wallet as the authorization principal via account-linking.

- Migration auth_identity_links (supabase_user_id ↔ wallet).
- supabaseUser.js: verify a Supabase access token via supabase.auth.getUser
  (no local JWT secret needed); x-supabase-token header.
- identity-link repo + service (optionally mirrors email into wallet_contacts).
- auth.controller + /api/auth routes:
  - POST /link-wallet: requires a valid Supabase session AND a SIWS signature,
    records the link, returns the existing HMAC session bearer for the wallet.
  - POST /session-from-social: Supabase session → linked wallet → session bearer
    (409 needsLink if not linked). Reuses issueSessionToken so ALL existing
    route middleware authorize unchanged.
- CORS allows x-supabase-token. 7 new tests; full suite green (271).
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stadium Ready Ready Preview, Comment May 22, 2026 2:53am

@sacha-l sacha-l marked this pull request as ready for review May 22, 2026 13:59
@sacha-l sacha-l merged commit 7de0982 into develop May 22, 2026
2 checks passed
sacha-l added a commit that referenced this pull request May 22, 2026
…k-bridge

chore(auth): remove unused social account-linking bridge (#152)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant