Sync Fortify and Passkeys updates

Merged
BI
2mo ago
+981-614

This finishes the Fortify update to laravel/fortify 1.x and brings Passkeys up to laravel/passkeys-server main. It also fixes the queue name in Horizon's job migration events on Redis Cluster, restores Laravel's protected console kernel hooks, and fixes smaller framework, documentation and package issues found along the way. docs/upstream-sync/sync.yaml records the upstream revisions both packages were reviewed against.

Upstream Updates

Fortify

  • laravel/fortify#654 corrected the documented return type of EmailVerificationNotificationController::store(). Hypervel declared it, EmailVerificationPromptController::__invoke() and TwoFactorAuthenticatedSessionController::store() as returning mixed. They now declare JsonResponse|Responsable, Responsable and Response|TwoFactorLoginResponse. The constructor docblocks upstream has in five controllers are restored.
  • laravel/fortify#659 made the stub imports consistent, which Hypervel's stubs already were. The PasswordValidationRules stub also had a comment saying Hypervel uses the framework password rule instead of Fortify's deprecated one. Upstream's stub uses the framework rule too, so the comment described no difference, and every application that installed Fortify got a copy of it. It's removed.
  • laravel/fortify#668 added passkeys, which Hypervel's Fortify already supports. The Fortify docs now show the JavaScript client, including per-call route overrides, and its React, Vue and Svelte helpers. They also explain the redirects that non-JSON requests receive and that a passkey confirmation satisfies the current guard's password.confirm middleware.
  • laravel/fortify#694 lets applications replace the recovery code generator with Fortify::generateRecoveryCodesUsing(), which RecoveryCode::generate() calls for each code. Like Fortify's other boot-time callbacks, it's held in a private static property with a getter and a flushState() reset, rather than upstream's public static property. Upstream doesn't document the option, so the Fortify docs gain a short example.
  • laravel/fortify#696 fixed a repeated enable request deleting a secret that was still waiting for confirmation. Hypervel already kept the secret, but the settings page then saw a stale two_factor_confirming_at session value, treated the pending setup as abandoned and disabled two-factor authentication. TwoFactorAuthenticationController::store() now clears that value while a secret awaits confirmation, so the next page load starts a fresh confirmation window.
  • laravel/fortify#697 runs the credential check before the two-factor challenge in a Timebox, so response times don't reveal whether a username exists. Hypervel uses the auth.timebox_duration setting that SessionGuard already uses, instead of upstream's fixed 200ms, and returns early once the credentials are valid, as SessionGuard does. Only failed attempts wait for the full duration.
  • laravel/fortify#699 moved upstream's tests from Mockery to the Double library and rewrote many of them to use real users, password reset tokens, notifications, views, rate limiting and guards. Hypervel keeps Mockery but ports those rewrites across ten controller test files, so the tests check persisted state, sent notifications and authentication results instead of mock calls. Two existing tests now check what they claim to: the login tests' false remember case sent the same payload as the null case, and the email verification helper now checks that the email was verified, not just the redirect.
  • laravel/fortify#701 fixed two two-factor responses implementing the wrong contract. Hypervel's responses were already correct. Upstream's binding test is ported, and it resolves all twenty response contracts through the container, replacing a narrower provider test.

Passkeys

  • The passkey controllers and PasskeyVerificationRequest share one verification session slot for login and confirmation again, with upstream's parameterless verificationOptions() (laravel/passkeys-server@7280c5b, laravel/passkeys-server@208d206). Hypervel had separate login and confirmation keys and made callers pass the key, which changed a public request method's signature. Login requires a guest and confirmation an authenticated user, so only one of them can be pending on a guard. Hypervel applications can use several guards in one session, though, so verification and registration options are now stored per guard, and a ceremony on one guard no longer replaces another guard's pending options. The controllers also resolve their responses through app() again, like upstream.
  • VerifyPasskey::getPasskey() takes upstream's credential and lock arguments again (laravel/passkeys-server#12). Hypervel had added an owner type argument, so passwordless logins only found passkeys owned by the guard's provider model, but an override written against upstream's public signature then failed with a fatal error. That check now happens in resolvePasskeyOwner(), which compares the stored owner type with the provider's model before loading the owner. Passkeys owned by another provider's model, or by a type that can't be resolved, are still rejected.
  • Verification still runs the transaction and row lock from laravel/passkeys-server#15 on the passkey model's own connection, so the lock holds when passkeys live on a non-default connection. It now does that through the DB facade, as upstream does. The connection test uses a real SQLite connection and checks that the lookup happens inside the transaction.
  • PasskeyRegistrationResponse::withPasskey() sets the passkey on the response and returns it, as upstream does (laravel/passkeys-server@7280c5b). Hypervel returned a modified clone, because resolving the concrete class gave one instance shared by the whole worker, which would carry one request's passkey into another. An upstream-style override that ignored the return value then rendered no passkey. The response is now Transient, so every resolution is fresh, and the passkey is a protected property that subclasses can read again.
  • DeletePasskey deletes the passkey it's given and dispatches PasskeyDeleted, like upstream (laravel/passkeys-server@7280c5b). Hypervel also required the actor to own the passkey and threw a 403 otherwise. The route already enforces ownership through the owner-scoped {passkey} binding, so the extra check only blocked direct calls, such as an administrator removing a user's passkey. The split package no longer requires symfony/http-kernel.
  • Passkey deletion is no longer throttled, in standalone Passkeys or in Fortify's passkey routes. Upstream throttles only login, confirmation and registration (laravel/passkeys-server#16). Deletion still requires authentication and password confirmation, and only reaches the user's own passkeys.
  • WebAuthn user handles now include the owner's morph class, along with the table and primary key that laravel/passkeys-server#5 uses. Upstream has one user model, but Hypervel's passkeys have polymorphic owners, and two owner models can read the same table, such as a model and its subclass. They got the same user handle, and since an authenticator keeps one passkey per relying party and user handle, registering a passkey for one owner replaced the other's passkey on that device. The Fortify docs explain how handles are derived, and how applications whose tenant databases share a relying party can add a tenant identifier.
  • The Passkeys README's differences list now includes the owner-scoped {passkey} binding, which returns 404 for another user's passkey where upstream returns 403 (laravel/passkeys-server#14). It also covers the private $passkeyModel property, which applications set through usePasskeyModel(), and the omitted StorePasskey::ensureCredentialIsUnique() check, since the unique credential_id index already rejects duplicates. Two entries that described internal details rather than public differences are removed.

Additional Hypervel Fixes

  • Horizon's JobsMigrated event named the queue after the Redis key that jobs were migrated into. On Redis Cluster that key has a hash tag, so the event reported {critical} while every other Horizon event reported critical, and a getQueueRedisKey() override, such as a tenant prefix, leaked into the name the same way. Horizon's pop() now keeps the resolved queue name in coroutine context while the base queue migrates jobs, and the event uses it. Direct migrateExpiredJobs() calls still report their own destination, and the base queue keeps Laravel's storage path and its protected getQueueRedisKey() hook. Horizon has the same problem upstream.
  • The console kernel's schedule(), commands() and load() methods are protected again, as in Laravel, and are no longer part of the kernel contract. Hypervel had made them public, so an application kernel ported from Laravel with protected overrides failed with a fatal visibility error. resolveConsoleSchedule() and addCommandPaths() remain the public entry points, and the Artisan facade's docblock drops the three methods.
  • Custom validation messages for missing_unless, present_unless, mimes, mimetypes and extensions now support capitalized and uppercase placeholders, such as :Other and :VALUES, like the other rules. Custom display values still don't apply to MIME types or extensions. Laravel has the same gap.
  • whereColumn('a', '<=>', 'b') now compiles to each database's null-safe comparison, as where('a', '<=>', $value) does since laravel/framework#58962. It used to emit MySQL's <=> on every driver, which SQLite and PostgreSQL reject. SQLite now uses is, and PostgreSQL is not distinct from. orWhereColumn() and join conditions take the same path, and the query builder docs show the operator. Laravel has the same gap.
  • The has-through relationship annotations give HasOneOrMany and MorphOneOrMany all three of their template types. Two database-wide PHPStan ignores, generics.lessTypes and generics.notSubtype, hid the missing type and would have hidden other generic mistakes too, so they're removed. The type fixtures cover through() with a relationship name and a through()->has() callback.
  • Sentry requires sentry/sentry ^4.32 instead of dev-master. Hypervel's coroutine runtime context needed the SDK's RuntimeContext API before it was released. Sentry 4.32.0 ships it, so installs no longer resolve whatever development commit is current.
  • The request docs cover float(), and the migration docs show DB::prohibitDestructiveCommands(), which stops db:wipe, migrate:fresh, migrate:refresh, migrate:reset and migrate:rollback even with --force. Laravel's docs mention neither.
  • Twelve package READMEs no longer link the Hyperf packages their code originally came from. Hypervel maintains that code independently, and Ported from links are for upstreams a package still tracks. The contracts README keeps only its Laravel Contracts link, and the Redis README now links Laravel's Redis component, whose API it follows. The licenses are unchanged.
  • A Recaller test that repeated the id and token getter tests is removed.
  • AGENTS.md lists the directories the Redis workflow actually runs and includes APC / APCu among the unsupported cache drivers.

The full test suite, the Testbench package-mode suite, formatting and static analysis pass locally with SQLite and Redis. CI runs the MySQL, MariaDB, PostgreSQL and other service suites.

[!NOTE]

Sync Fortify and Passkeys upstream updates

  • Passkey ceremony options are now stored per guard: PasskeyRegistrationRequest::registrationOptions and PasskeyVerificationRequest::verificationOptions use keys suffixed with the guard name (e.g. passkey.verification_options_web), and the login/confirmation/registration controllers write to guard-scoped session slots
  • DeletePasskey no longer checks ownership or requires a PasskeyUser; it deletes the supplied passkey and dispatches PasskeyDeleted with the given actor
  • VerifyPasskey::getPasskey drops the owner-type query filter and resolvePasskeyOwner now rejects stored owner types that differ from the expected guard owner type before resolving the relation
  • PasskeyAuthenticatable::getPasskeyUserHandle includes the model's morph class in the HMAC input, so owners sharing a table produce different handles
  • Other fixes: RecoveryCode::generate uses a callback registered via Fortify::generateRecoveryCodesUsing; RedirectIfTwoFactorAuthenticatable::validateCredentials runs failed validation through a timebox; ReplacesAttributes MIME/extension replacements support case variants; Grammar::whereColumn compiles null-safe <=> comparisons; Console\Kernel::schedule/commands/load are now protected and removed from the kernel contract; PasskeyRegistrationResponse::withPasskey mutates and returns the same instance
  • Behavioral Change: the passkey deletion route drops throttle middleware, Fortify controllers return concrete response types instead of mixed, JobsMigrated events fired during RedisQueue::pop now report the resolved queue name, and EmailVerificationPromptController::__invoke requires a Responsable return value

Macroscope summarized 67a09c6.

Summary by CodeRabbit

  • New Features

    • Recovery codes can now be generated with a custom callback.
    • Column comparisons support <=>, treating two NULL values as equal.
    • Passkey user handles distinguish different model types, and passkey verification options are handled consistently across login and confirmation.
    • Validation messages preserve placeholder casing for conditional rules, extensions, and MIME types.
  • Bug Fixes

    • Failed two-factor login attempts now observe the configured authentication delay; successful attempts skip the wait.
    • Queue migration events report the correct queue name, including during concurrent processing.
    • Passkey deletion no longer receives the passkey-specific throttle; authentication and optional password confirmation remain in place.
  • Documentation

    • Added guidance for passkeys, recovery-code customization, safer production migrations, null-safe column comparisons, and retrieving float request input.