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

Can not verify the code generated by Google Authenticator app after deploying the code on the server #98

Open
ashish-devclever opened this issue Nov 1, 2021 · 0 comments

Comments

@ashish-devclever
Copy link

Hi,

I have used this library to enable the 2FA in our app. It is working absolutely working fine on my local environment but when we deployed the code on staging it is not able to validate the verification code generated by Google Authenticator app.
Both the environments are using Php 7.3. and according to the the issue #61, the mbstring.func_overload value is already set to 0. The only deference I can see the default timezone. On server it is Europe/London where as in local it is UTC. I have also changed in my local system to Europe/London even it is working fine. Attached is the configuration in php.ini of server for your reference.

Screen Shot 2021-11-01 at 10 50 07 PM

I have also made the suggested changes in getCode function as mentioned in the #61.

// last arg: When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits.
// hex string would be more stable in PHP I guess.
$hm = hash_hmac('SHA1', $time, $secretkey, false);

// last nibble is the last hex symbol now. Just turn it to decimal.
$offset = hexdec(substr($hm, -1));

// as each byte is 2 hex symbols, multiply 'substr' args by 2
// turn resulting hex into binary for compliance with further code
$hashpart = hex2bin(substr($hm, $offset * 2, 8));

But still no luck. It would be a great help if anyone can help on this to resolve.

Thanks and Regards
Ashish

@ashish-devclever ashish-devclever changed the title Can verify the code generated by Google Authenticator app on deploying the code on server Can not verify the code generated by Google Authenticator app on deploying the code on server Nov 2, 2021
@ashish-devclever ashish-devclever changed the title Can not verify the code generated by Google Authenticator app on deploying the code on server Can not verify the code generated by Google Authenticator app after deploying the code on the server Nov 2, 2021
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

No branches or pull requests

1 participant