scheb / 2fa

Two-factor authentication for Symfony applications 🔐
MIT License
495 stars 72 forks source link

"User is in a two-factor authentication process" exception picked up by sentry #238

Closed kov-lucas closed 6 days ago

kov-lucas commented 1 month ago

Bundle version: 7.5.0 Symfony version: 6.4.9 PHP version: 8.3.7

Description

We are using sentry and scheb/2fa

We noticed that sentry is picking up an exception "User is in a two-factor authentication process.", and we are not sure why, but it seems to happen quite often. Is this an implementation error? Sentry picking up something it shouldn't? What's the purpose of this exception?

scheb commented 1 month ago

This is an AccessDeniedException that is raised by the bundle whenever someone tries to access a protected route, while they're still in the process of entering the 2fa code.

See: https://github.com/scheb/2fa/blob/642dbafe8c6aca8390fb4b45e8ed634c2e3d9567/src/bundle/Security/Http/Firewall/TwoFactorAccessListener.php#L58

kov-lucas commented 1 month ago

Doing a quick test, on such case, I'm being redirected to set the verification code, so why there's also an exception?

Wouldn't a return; make more sense?

stale[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

kov-lucas commented 6 days ago

I still need an answer here 😅