Upgrading From Fortify
On this page
Introduction
Fortify is a PHP package, so there's no Fortify for Go to upgrade from. This page is for a Laravel for Go application that takes over users from a PHP application that used Fortify, sharing its database.
Your users keep their passwords, as long as they're bcrypt hashes: Laravel for Go checks no other kind. The PHP package's two caveats still apply (passwords over 72 bytes on a bcrypt hash, and passwords typed in a form other than NFC). Their authenticator apps, recovery codes and passkeys come over too: Keyring for Go's keyring:import fortify reads Fortify's two-factor columns, and laravel/passkeys' passkeys, into Keyring's tables, as the PHP package's does.
Steps
-
Add Keyring for Go, as Installation shows, with the sign-in methods your users already have: authenticator apps and recovery codes for Fortify's two factor, and passkeys for
laravel/passkeys. They're all on by default. Use the PHP application'sAPP_KEY. -
Run the migrations, which create Keyring's tables beside Fortify's columns:
Terminalgo run . migrate -
Import your two-factor data and passkeys. Run a dry run first:
Terminalgo run . keyring:import fortify --dry-rungo run . keyring:import fortifyThe command exits non-zero if any factor couldn't be imported. Fix those before you go on. See Importing Two-Factor Data.
-
Move your settings into
keyring.Configand the*Keyring, using the tables below, and turn on the features you used. -
Point your frontend at the challenge page and the authenticator routes.
-
Once everything works, drop Fortify's columns in a migration of your own.
Replacing Fortify in a Starter Kit
Laravel's starter kits are PHP. For a new Laravel for Go application, start from Keyring's own starter kit instead, which has a page for every page Keyring renders but the sign-in-link page (which only matters with WithLink() on), in React.
Importing Two-Factor Data
keyring:import fortify copies what the PHP package's does, with --dry-run, --unconfirmed and --fortify-confirm: each user's two_factor_secret into a totp authenticator, their two_factor_recovery_codes into a recovery authenticator as keyed hashes of the codes as Fortify showed them, and each laravel/passkeys row into a passkey authenticator. It only fills in users with no sign-in methods in Keyring yet, leaves a stand-in that keeps the user challenged when a secret can't be read, and never touches Fortify's columns or the passkeys table. It reads from the database's writer, not a read replica. The PHP docs describe each rule.
The Go command differs in a few ways:
- The table. It reads Fortify's columns from the table
SessionUserTypenames, or the one--tablenames, and warns that it files every row underAuthenticatableTypewhen that's another table. It readspasskeys.user_idagainst the same table. A table withouttwo_factor_recovery_codesortwo_factor_confirmed_atreads them as null. - Keys. It decrypts with the application key, where the PHP package asks Fortify for its encrypter. If the PHP application used
Fortify::encryptUsing(), import from the PHP side instead. - Confirmation. It can't read
config/fortify.php, so pass--fortify-confirm=onoroffwhen some users never confirmed their secret, or--unconfirmedto import them anyway. Without either, such a user counts as failed. - Recovery codes. They must decrypt to a JSON list of strings. Anything else counts as failed, with a stand-in left in their place.
- Passkeys. One that can't sign in here, an RS256 key while
WebAuthn.Algorithmsleaves it out say, is still imported, since it may be the user's only method, and listed with the PHP package's warnings, namingWebAuthn.AlgorithmsandWebAuthn.MinimumRSABitswhere they nameconfig/keyring.php. It counts as refused when Keyring for Go couldn't read its key or wouldn't take it. - Factors. With rows in
passkeys, it refuses to run untilFactors.Passkeysis on, as the PHP package asks you to register passkeys first. Passkeys are on unless you turned them off.
How Fortify Concepts Map
Configuration
| Fortify | Keyring |
|---|---|
fortify.guard |
Guard, which only names Laravel for Go's one session guard |
fortify.username |
Username |
fortify.lowercase_usernames |
Always on. |
fortify.home |
Home |
fortify.prefix |
Prefix |
fortify.domain |
Not available. |
fortify.middleware |
Not available: turn Routes off and call Routes() in a group of your own. See Routes. |
fortify.passwords |
Passwords.ResetLinkFor and Passwords.ResetThrottle |
fortify.views |
Pages |
fortify.limiters |
Limits |
Features::registration() and the rest |
Features.Registration, ResetPasswords, EmailVerification and UpdatePasswords |
Features::updateProfileInformation() |
Not included. Keep your own profile route, with GuardChanges in the user model's Updating hook. |
Features::twoFactorAuthentication() |
Authenticator apps and recovery codes (on by default), Features.ManageAuthenticators, and a policy. |
Actions
| Fortify | Keyring |
|---|---|
CreateNewUser |
A CreatesNewUsers given to CreateUsersWith(): validation in Validate(), without checking whether the address is taken, and saving in Create(). |
ResetUserPassword |
A ResetsUserPasswords given to ResetPasswordsWith(). |
UpdateUserPassword |
An UpdatesUserPasswords given to UpdatePasswordsWith(). Keyring checks current_password itself. |
PasswordValidationRules |
PasswordRules. See Password Rules. |
UpdateUserProfileInformation |
Your own code, with email changes through a ValidatesEmailChanges and Keyring's flow. |
Fortify::authenticateUsing() |
Your auth.Users, given to FindUsersWith(). Keyring checks the password itself. |
Fortify::confirmPasswordsUsing() |
Not needed. Step-up accepts any qualifying factor. |
The contract app's actions are Keyring's PHP stubs written in Go.
Views and Pages
The pages are the PHP package's, as its table maps them: login, register, forgot-password, reset-password, verify-email, email-verification, challenge and confirm. They're always the Inertia components auth/{page}.
Routes
The routes are the PHP package's, with the same names, as its table maps them. There's no Laravel password.confirm middleware to keep working: use RequireFreshVerification.
Responses
There's no way to replace Keyring's responses yet, so there's nothing in place of Fortify's LoginResponse, TwoFactorLoginResponse and the rest. A refusal is Laravel for Go's validation error. See Responses.
Events
The events map as in the PHP table, as Keyring's own event types, such as keyring.Authenticated[U]. Laravel for Go dispatches none of Laravel's Login, Logout, Failed or Lockout. Keyring dispatches its own Registered[U], Verified[U], PasswordReset[U] and PasswordChanged[U] in their place. See Events.
Rate Limiting
Keyring limits every factor per account and per address inside the pipeline, using Limits, as in the PHP package. There are no named limiters to define: the keyring limiter is Limits.Forms and Limits.GuestForms. See Rate Limiting.
Things That Behave Differently
As the PHP docs list, plus:
- A password change ends every other session, whatever
sign_out_otherssays, since Laravel for Go's guard signs out every session made with the old password anyway. - Registration, resets, email verification, password changes and email changes start off, and each needs its action.
- Saving a user doesn't check protected attributes by itself: call
GuardChangesfrom the user model'sUpdatinghook, and before any write that doesn't go through the model. - Argon2 passwords can't be checked. Laravel for Go checks bcrypt alone.