-
Notifications
You must be signed in to change notification settings - Fork 77
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
Two-factor authentication form is not shown after login #23
Comments
Some things that I'd like to clarify before we dive deeper. Because to me everything seems to look fine.
You're definitely not logged in normally, because
What route did you use? I have doubts because it reads as if your whole application allows anonymous access (many |
@scheb Thanks for getting back to me so quickly.
I used the One thing that now hits me as potentially relevant is that I have a setup where the roles are not stored as part of the user entity, but rather on an entity associating the user with a tenant. So I am, among other things, extending the |
Yes, the voter could definitely be relevant. Here the bundle is checking if the path is accessible during 2fa and should throw an exception to redirect to the 2fa form: 2fa/src/bundle/Security/Http/Firewall/TwoFactorAccessListener.php Lines 80 to 85 in ed2ce98
which uses the application's 2fa/src/bundle/Security/Authorization/TwoFactorAccessDecider.php Lines 57 to 59 in 1316a77
To avoid any side effects, in your voter you could skip any special rules for a token of type |
Thanks so much for the tip! I'll look into this and update the issue once I have a little more time. |
I have indeed confirmed that both However, it is not clear to me what this means (or what exactly is going on here). I'm attaching a dump of the Am I reading this dump correctly in that the third voter (
It's not clear to me what this entails specifically. Here's the contents of the the
|
The issue is, your This should fix the problem: use Scheb\TwoFactorBundle\Security\Authentication\Token\TwoFactorTokenInterface;
protected function extractRoles(TokenInterface $token)
{
if ($token instanceof TwoFactorTokenInterface) {
return [];
}
// Your code here ...
} |
@scheb That worked like a charm - thanks a lot! Do you find it relevant to update the troubleshooting documentation, or do you consider my setup too specific to be generally relevant? |
Glad to hear it worked! Yes, I was also thinking about extending the troubleshooting guide a bit. There was another use-case when someone was doing something with the roles and because of that 2fa didn't work as expected. I'd like to mention that in the guide, to make people aware this could be an issue. How would you describe your use-case, ro rather what could we add to the troubleshooting guide that would have helped? You can just post it here, I'm gonna combine it with the other use-case then. |
I think my use case would be best added somewhere near the "No" option of the second question under the "Two-factor authentication form is not shown after login" issue. I'm not certain that I understand the problem sufficiently in order to formulate an addition, but instead of just saying "Unknown issue", it might be useful here to mention that if you have a somewhat custom security setup, you might run into issues where an existing voter grants access in a way that does not comply with the bundle. It might even be helpful to link to this issue for a specific example. |
Oke, I'll add a section on custom security setups. What this issues all have in common is, that the customization is doing something with the roles. Good idea to add the issues for reference, I'm going to do that. Closing this issue now. |
Bundle version: 5.1.0
Symfony version: 5.1.3
Description
I'm attempting to get the two-factor authentication form to appear for a user which has a
googleAuthenticatorSecret
. The secret has been created by the service auto-injected for theGoogleAuthenticatorInterface
.However, when I attempt to log in, I'm logged normally, without ever being sent to
2fa_login
route to inout the two factor code. The debug toolbar indicates that I do receive theScheb\TwoFactorBundle\Security\Authentication\Token\TwoFactorToken
, though.I've tried following https://github.com/scheb/2fa/blob/5.x/doc/troubleshooting.md#two-factor-authentication-form-is-not-shown-after-login and discovered the following:
Scheb\TwoFactorBundle\Security\Authentication\Provider\AuthenticationProviderDecorator::authenticate()
?: YesScheb\TwoFactorBundle\Security\TwoFactor\Handler\TwoFactorProviderHandler::getActiveTwoFactorProviders()
called?: YesScheb\TwoFactorBundle\Security\TwoFactor\Handler\TwoFactorProviderHandler::getActiveTwoFactorProviders()
return any values?: Yes:The only time I'm able to trigger the two factor authentication form is when I start of by going to the
2fa_login
route (/2fa
). In that case, I get redirected to the 2fa input form after providing my username and password, and the authentication appears to work as expected.The content of my
security.yaml
file is as follows:The text was updated successfully, but these errors were encountered: