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

Error scanning QR code #1

Open
flyinliamryan opened this issue Jan 5, 2024 · 2 comments
Open

Error scanning QR code #1

flyinliamryan opened this issue Jan 5, 2024 · 2 comments

Comments

@flyinliamryan
Copy link

Hi Jako,

I tested TwoFactorX out on a dev site. Scanning the QR code with both Google and Microsoft Authenticator generates errors. This occurs during the courtesy login process and also within the user profile section.

Google - "Error - Cannot interpret QR code"
Microsoft - "QR code is invalid."

Keying the secret manually works fine.

@flyinliamryan
Copy link
Author

📍 File: GoogleAuthenticator.php

The method getUri incorrectly applies URL encoding to the entire URI for generating QR codes. This results in the Authenticator failing to interpret the QR code correctly, as the otpauth://totp/ part should not be URL-encoded.

Current Implementation:

public function getUri($accountname, $secret, $issuer)
{
    return urlencode('otpauth://totp/' . $accountname . '?secret=' . $secret . '&issuer=' . $issuer);
}

Issue:
The urlencode function should not be applied to the entire string. Instead, it should only encode the accountname and issuer parts to handle special characters.

Proposed Solution:

public function getUri($accountname, $secret, $issuer)
{
    $encodedAccountName = urlencode($accountname);
    $encodedIssuer = urlencode($issuer);
    return 'otpauth://totp/' . $encodedAccountName . '?secret=' . $secret . '&issuer=' . $encodedIssuer;
}

@DESIGNfromWITHIN
Copy link

I also get this issue, see a blank field where the QR code should be on setup.

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

2 participants