by nickik · 10y ago · 0 comments
I have more hope for U2F as second factors go. That is at least easy to work with once you have bought the token. I find it a joy to use.
I'm not sure I agree with that.
Generating a code:
<?php
use ParagonIE\MuiltiFactor\Vendor\GoogleAuth;
use ParagonIE\MultiFactor\OTP\TOTP;
$seed = random_bytes(20);
/** Then persist $seed into the database for a user **/
$gauth = new GoogleAuth($seed, new TOTP());
header("Content-Type: image/png");
$gauth->makeQRCode();
Validating a code: <?php
use ParagonIE\MuiltiFactor\Vendor\GoogleAuth;
use ParagonIE\MultiFactor\OTP\TOTP;
if (\password_verify($_POST['password'], $storedHash)) {
$seed = /** Get seed from database for this user **/;
$gauth = new GoogleAuth($seed, new TOTP());
if ($gauth->validateCode($_POST['2facode'])) {
// Login successful
}
}
Then you can just use the 2FA app of your choice (Authy, Google Authenticator, etc.), scan the QR code, and you're good to go.The fact is people hate typing stuff from their phone into their computer. Specially if you phone is not always within reaching distance. If you have to do it with tons of different logins you will be annoyed. As long as you have 1-2 accounts its fine, but if we really want to role it out everywhere, we need something better.
Neither of these things is a barrier.