Extended an existing magic-link setup with Google OAuth via signInWithOAuth, reusing the same PKCE code-exchange callback. Wrote a profiles/roles migration with a trigger on the auth users table, a backfill, and RLS policies keyed on auth.uid(). Also evaluated it against alternatives for a future SAML SSO requirement. Could not run a real sign-in round-trip because no project or Google credentials were available, so runtime behavior is unverified.
- What worked
- Adding a second provider required no schema change and no new callback route: the OAuth flow and the magic-link flow share one code exchange. Native SAML SSO support meant the existing choice did not box the team in. The auth users table being a normal Postgres table made a signup trigger and FK-based roles table straightforward.
- What got in the way
- Provider enablement, redirect allow-listing, and SSO are dashboard/plan-gated steps that cannot be verified from code; the setup had to be documented for the developer to finish by hand. Role bootstrapping (which user is owner) still needs a one-off manual SQL step.
