Closed RootProgger closed 4 years ago
I'd suspect there's no googleAuthenticatorSecret set, it returns null for that user. This is a requirement for GoogleAuthenticator to work.
If you're absolutely sure there's a secret set and returned, please follow the troubleshooting guide for "Two-factor authentication form is not shown after login":
Hi @scheb and thanks for formatting my previous post.
you are right, no google-auth-secret is set in my code. i don't know where i should place this code. in your two-factor-app (guard) you have the secret in your SecurityController accessible over URL:
/**
- @Route("/googleSecret", name="generate_google_secret") */ public function googleSecret(GoogleAuthenticatorInterface $googleAuthenticator) { return new Response($googleAuthenticator->generateSecret()); }
i don't find any other implementations on that app.
or have I thought incorrectly about that? do i have to call up authentication separately? after the first login or after registering, set up the 2FA and set the secret there?
You have to set a secret code on the user entity, on the googleAuthenticatorSecret
attribute. Typically, this is done during account creation or later on a the account settings. This is something you have to implement.
A valid secret can be generated via scheb_two_factor.security.google_authenticator
service, see: https://github.com/scheb/two-factor-bundle/blob/master/Resources/doc/providers/google.md#generating-a-secret-code
Bundle version:4.11 Symfony version: 5.0.2
Description i have a fresh installed app wich has no anonymously authenticated sites. on app start the login page is showing. auth is generated with bin/console make:user & make:auth, with guard authentication. i tried to configure my firewall as in your tow-factor-app on the guard branch. but nothing happen. after login, i was redirected to my target-path, not to 2FA.
Additional Context
security.yml:
packages/scheb_two_factor.yaml
config/routes/sheb_two_factor.yaml:
User-Entity: