RobThree / TwoFactorAuth

PHP library for Two Factor Authentication (TFA / 2FA)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QR Code doesn't work with Dashlane

DarkShoro opened this issue · comments

While Google Authenticator and Authy are able to scan and use the QR Code just fine, something in the secret make Dashlane not be able to scan it.

Any idea of why?

Unfortunately my crystal ball is out for repairs, so you'll have to fill us in into some of the details. What are the parameters you're creating the QR code with for example, so that we can try to reproduce and have a look at your actual values and see if there's something wrong with them.

I'm creating the QR Code with nothing else than the default parameters, also using default parameters for the
new TwoFactorAuth();

It's nothing but default.

It might not be the best code in the world; but here is a quick pick at my class


use RobThree\Auth\TwoFactorAuth;

class TwoFactor {

    public static function generateTFASecret() {
        $tfa = new TwoFactorAuth();

        $secret = $tfa->createSecret();

        return $secret;
    }

    public static function GenerateQRDataURIFromSecret($secret) {
        $tfa = new TwoFactorAuth();

        $qrCode = $tfa->getQRCodeImageAsDataUri("Hydra-Shield", $secret);

        return $qrCode;
    }

    public static function addSecretToUser($userId, $secret) {
        
        $GLOBALS['DB']->Insert("account2fa", [
            "userId" => $userId,
            "secret" => $secret
        ]);

        return true;
    }

    public static function isUserUsingTFA($userId) {
        
        if ($GLOBALS['DB']->Count("account2fa", ["userId" => $userId]) == 0) {
            return false;
        }

        return true;
    }

    public static function getSecretFromUser($userId) {
        $secret = $GLOBALS['DB']->GetContent("account2fa", ["userId" => $userId])[0]['secret'];

        return $secret;
    }

    public static function verifyCodeOnSetup($secret, $code) {
        $tfa = new TwoFactorAuth();

        $result = $tfa->verifyCode($secret, $code);

        return $result;
    }

    public static function verifyCode($userId, $code) {
        $secret = self::getSecretFromUser($userId);

        $tfa = new TwoFactorAuth();

        $result = $tfa->verifyCode($secret, $code);

        return $result;
    }

    
}

I'm creating the QR Code with nothing else than the default parameters, also using default parameters for the
new TwoFactorAuth();

It's nothing but default.

Yeah, but if you don't mention that how are we supposed to know? 😉

Could you show us a QR code that doesn't work? Or the DataUri?

The problem is kinda solved by itself.

There is two methods of adding a 2FA code on Dashlane, one of them don't work, but the other do, so it's not a you problem.

Could you elaborate on what the two methods are and which of them works? For future reference...

If you go to the "Authenticator" page and click "Add a 2FA token", then scan the QR Code, the reading will fail and Dashlane will spill out an error

If you, however, go to your existing IDs, click the one from your website, edit it, and click "SETUP" on the 2FA part, then, the code will scan fine and be added to your account.

I hope I was clear enough.

That's really weird.

Would you mind sharing a (test) QR code with us so we can (try to) reproduce?

Here is one of the QR code generated

image

It scanned fine for me, first try? Deleted it, scanned it again, no problem. Are we talking iOS, Android?

I am talking Android, two of my friend plus me couldn't scan it in the "Authenticator" tab, but editing our profile with our existing info, then scanning the code there worked for us.

I'm sorry, that must be a Dashlane issue then. It scans perfectly fine for me on iOS. Maybe someone else can chime in?

seems fine for me, the URI encoded in the qr code looks fine too, you can use the Google Authenticator app to test it out with a different app on the same phone without having to set up a whole new account to confirm.