Skip to content
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

Fire ValidTwoFactorAuthenticationCodeProvided Event when 2FA session is authenticated #559

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

stefanzweifel
Copy link
Contributor

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

  1. 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.

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@stefanzweifel stefanzweifel marked this pull request as ready for review July 29, 2024 14:45
@taylorotwell
Copy link
Member

I would call the event something like ValidTwoFactorAuthenticationCodeProvided

@taylorotwell taylorotwell marked this pull request as draft July 30, 2024 06:54
@taylorotwell
Copy link
Member

Please mark as ready for review when the requested changes have been made.

@stefanzweifel stefanzweifel changed the title Fire TwoFactorAuthenticationVerified Event when 2FA session is authenticated Fire ValidTwoFactorAuthenticationCodeProvided Event when 2FA session is authenticated Jul 30, 2024
@stefanzweifel stefanzweifel marked this pull request as ready for review July 30, 2024 08:25
@stefanzweifel
Copy link
Contributor Author

@taylorotwell Definitely sounds and feels better than my original name. Thanks!

@taylorotwell taylorotwell merged commit 983daf0 into laravel:1.x Aug 1, 2024
7 checks passed
@stefanzweifel stefanzweifel deleted the 2fa-verified-event branch August 1, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants