-
Notifications
You must be signed in to change notification settings - Fork 310
Is TwoFactorAuthenticatedSessionController missing PrepareAuthenticatedSession? #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the clear issue. I'll let Taylor check in on these. |
@LeoniePhiline I think I got all of them. Taylor is going to review the PRs I made. Thanks for reporting 👍 |
I'm going to close this now that we merged the main PR for this. |
@driesvints The rate limiter still doesn't seem to be cleared after two factor login. This line is missing from the two factor login flow: |
@jandreasn can you send in a PR? |
@driesvints I was planning to but after looking into it a bit more I'm not sure what the best solution is. Clearing just the LoginRateLimiter is easy but there's another separate two factor limiter now too. |
Description:
Authentication with vs. without 2fa
When authenticating without the
Features::twoFactorAuthentication()
feature thenAuthenticatedSessionController
pipes$request
throughPrepareAuthenticatedSession
. If 2fa is used, though, then this step is skipped and we continue inTwoFactorAuthenticatedSessionController
.The latter still performs a
$session->migrate(true)
through$guard->login(...)
(likeAttemptToAuthenticate
for non-2fa logins), but does not regenerate the CSRF token ($session->regenerate()
), likePrepareAuthenticatedSession
would perform for non-2fa logins. Neither is the limiter cleared after successful 2fa login. These points made me wonder ifTwoFactorAuthenticatedSessionController
was missing a continuation ofAuthenticatedSessionController
's login pipeline.Missing login rate limiter increment at failed 2fa challenge
When failing to enter the correct 2fa code,
LoginRateLimiter::increment()
is not called - only if the initial password challenge fails. Doesn't this make brute-forcing the second factor possible?Using existing user provider methods
On a side note, I noticed that
RedirectIfTwoFactorAuthenticatable::validateCredentials()
performs its own credentials check, whereAttemptToAuthenticate::handle()
uses the provider'sretrieveByCredentials()
method. It might make sense to use\Illuminate\Contracts\Auth\UserProvider::retrieveByCredentials()
and\Illuminate\Contracts\Auth\UserProvider::validateCredentials()
inRedirectIfTwoFactorAuthenticatable
as well, instead of the current custom ad-hoc implementations, even if Fortify is meant to depend on Eloquent as users provider.The text was updated successfully, but these errors were encountered: