API

Social auth

19 steps 16 files 1 packages 1 dependencies

This pack adds social sign-in to your API. Because OAuth rides a full-page browser redirect, the backend runs the provider round-trip and hands the result back to your frontend, fitting the guard your app already authenticates with. It ships endpoints, not screens.

  • Fits your existing guard, a session guard's cookie rides the redirect, an access-token guard hands the frontend a one-time PKCE-bound code to exchange for a token.
  • Provider emails are trusted only when the provider verifies them, and an unverified one is routed through your existing email-verification flow.
  • An email that already belongs to a local account is refused rather than silently linked to the provider.
  • A password-less account cannot disconnect its last provider, so it can never lock itself out.
  • A methods endpoint reports the configured providers and the visitor's last-used one, so the client renders the right buttons without hardcoding them.
Depends on Auth

This pack extends the auth pack's User model and reuses its email-verification flow. Apply the auth pack first.

Apply the social auth pack with Flow. Start a new session in your selected coding agent and execute the following slash command inside it.

$ claude
> /flow.apply social-auth

After applying, Flow will make the following changes to your app.

  • Discover your default guard, access tokens or session, and the frontend URL your OAuth callback redirects to.

  • Land the backend as shipped, from the social_identities migration and the nullable-password change through the withSocialIdentity() model mixin, the guard-branched OAuth redirect and callback controller, the public methods endpoint, and the connected-accounts endpoints. On a tokens guard it adds the PKCE token-exchange endpoint.

  • Configure the providers you pick, Google and GitHub by default, record the last-used method on your existing login and signup, and add the two-factor branch when your app already has two-factor.

  • Run the tests, drive the endpoints, and hand you a brief for the frontend to build against.

Terms & License Agreement