API

Two-factor auth

18 steps 14 files 2 packages 1 dependencies

This pack adds two-factor authentication to your API as JSON endpoints. It fits the guard your app authenticates with, access tokens or session, and enhances your existing login rather than replacing it.

  • Enrollment endpoints that return the QR code and secret, confirmed with a six-digit code.
  • One-time recovery codes returned once in the response, which the client can regenerate.
  • A login that returns a short-lived, purpose-bound challenge token for a two-factor user, exchanged with a code at a rate-limited challenge endpoint.
  • An email to the account owner whenever two-factor is turned on, turned off, or its recovery codes change.

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

$ claude
> /flow.apply two-factor

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

  • Discover your default guard, access tokens or session, so the challenge finishes on the credential you already issue.

  • Land the backend as shipped, from the migration and model mixin through the validators, the enrollment, recovery-codes, and challenge controllers, routes, and the change-notification mailer.

  • Enhance your login to return a challenge token for a two-factor user instead of the credential.

  • Run the tests, then drive the enrollment, recovery-codes, and challenge endpoints and show you the responses.

Terms & License Agreement