Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Doesn't work in PROD works in DEV #298

Closed
jimiero opened this issue Sep 9, 2020 · 2 comments
Closed

Doesn't work in PROD works in DEV #298

jimiero opened this issue Sep 9, 2020 · 2 comments
Labels

Comments

@jimiero
Copy link

jimiero commented Sep 9, 2020

Bundle version: latest version
Symfony version: 4.4

Description

I managed to make it work just fine in localhost, but when I try to use on PROD it always fails when I use:

$this->googleAuthenticator->checkCode($user, $code)

Additional Context
Any idea what may be the cause of the issue?

@jimiero jimiero added the Support label Sep 9, 2020
@scheb
Copy link
Owner

scheb commented Sep 9, 2020

The principle of TOTP/Google Authenticator is that both devices generate a code based on time + secret. If one of those two components isn't in sync, they'll generate a different code. So:

  • Check the secret used in your device matches the secret configured for the account
  • Check the server time is in sync with your device time, ideally both are in sync with UTC (most common reason for this issue)

The time window for each code is 30 seconds, so if the time difference between server/device is too large codes will be out-of-sync and it will be hard or impossible to hit the right code. You could also increase the window setting, so accept more codes around the current valid one:

# config/packages/scheb_two_factor.yaml
scheb_two_factor:
    google:
        window: 1  # How many codes before/after the current one would be accepted as valid

@jimiero
Copy link
Author

jimiero commented Sep 9, 2020

Thanks @scheb that was the issue, server had a wrong un-synced time date, solved that and now worked.

Best regards!

@jimiero jimiero closed this as completed Sep 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants