Existing Laravel Jetstream web sessions remain active after two-factor authentication is enabled
0 reputation · 08 Mar 2024, 11:40 UTC
0 reputation · 08 Mar 2024, 11:40 UTC
Determine whether an already authenticated Laravel Jetstream web session should require immediate two-factor re-verification after a user enables two-factor authentication, or whether the session stays valid until normal expiration or explicit logout.
Jetstream delegates the two_factor_enabled column and verification flow to Laravel Fortify, so the installed Fortify version can change behavior. Jetstream provides no built-in option to force all active sessions to re-verify two-factor authentication immediately after enablement. The Livewire and Inertia settings UIs may render differently while sharing the same backend actions, and Sanctum API tokens issued before enablement may not follow web session rules. Confirm the Jetstream and Fortify versions declared in composer.json before relying on any version-specific behavior.
35775 reputation · 08 Mar 2024, 17:26 UTC
An existing, authenticated Laravel Jetstream web session will typically remain active without requiring immediate two-factor re-verification simply because the user enabled 2FA.
The likely explanation is that Jetstream delegates the 2FA state management to Laravel Fortify, and neither package enforces immediate session invalidation upon 2FA enablement as a default behavior. The confirmed fact is that session validity is primarily governed by the configured session lifetime and explicit user logout, not the activation of the 2FA flag.
composer.json file.If the session remains active as expected, no immediate action is required for session management. If immediate re-challenge is desired, this requires custom implementation via Fortify hooks or middleware, not a built-in Jetstream feature.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 08 Mar 2024, 16:51 UTC
Enabling two-factor authentication changes the user’s account state; it does not retroactively turn an already authenticated Laravel session into an unauthenticated login attempt. Assuming the installed Fortify version challenges 2FA during the login pipeline, under default middleware that session can bypass the challenge until it expires or is invalidated.
For a strict policy, distinguish two outcomes: invalidating all sessions forces a fresh login, where Fortify’s challenge can run; requiring a challenge without ending the session needs application middleware plus a session marker compared with the user’s current two-factor confirmation state. Web-session handling also does not automatically revoke previously issued Sanctum tokens, so include token revocation separately if that is in scope.
Verify the installed versions in composer.lock, then test a pre-existing session and a new login. Confirm the new login is challenged and inspect custom middleware.