Fire ValidTwoFactorAuthenticationCodeProvided Event when 2FA session is authenticated #559
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In an app I'm working on we would like to store a timestamp in the session, when the user last verified their 2FA1. While source-diving I didn't find an event that would be fired, when the 2FA code was verified. (There are only events for when the verification failed.)
This PR adds a new event that is being fired when a new session is being authenticated using 2FA. Adding an event listener for our usecase is now trivial.
I was contemplating if this event should be fired within the
TwoFactorAuthenticationProvider
, but as no other events are fired within that implementation I think the controllers is the right place for them.Footnotes
In our app, the admin panel is protected with a
RequireTwoFactorAuthentication
-middleware that periodically asks users to confirm their 2FA code. (Similar to the\Illuminate\Auth\Middleware\RequirePassword
-middleware).We currently run into an UX-issue where folks can't access the admin dashboard immediately after login, as the same 2FA code doesn't seem to be accepted by the
TwoFactorAuthenticationProvider
within the 30s window after login. ↩