This commit is contained in:
Alexey Berezhok
2024-03-19 22:05:27 +03:00
commit 346a50856b
1572 changed files with 182163 additions and 0 deletions

23
web/inc/2fa/check.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
use RobThree\Auth\TwoFactorAuth;
require_once __DIR__ . "/../vendor/autoload.php";
if (isset($argv[1]) && isset($argv[2])) {
$secret = $argv[1];
$token = $argv[2];
} elseif (isset($_GET["secret"]) && isset($_GET["token"])) {
$secret = htmlspecialchars($_GET["secret"]);
$token = htmlspecialchars($_GET["token"]);
} else {
echo "ERROR: Secret or Token is not set as argument!";
exit();
}
$tfa = new TwoFactorAuth("Hestia Control Panel");
// Verify code
$result = $tfa->verifyCode($secret, $token);
if ($result) {
echo "ok";
}

10
web/inc/2fa/secret.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
use RobThree\Auth\TwoFactorAuth;
require_once __DIR__ . "/../vendor/autoload.php";
$tfa = new TwoFactorAuth("Hestia Control Panel");
$secret = $tfa->createSecret(160); // Though the default is an 80 bits secret (for backwards compatibility reasons) we recommend creating 160+ bits secrets (see RFC 4226 - Algorithm Requirements)
$qrcode = $tfa->getQRCodeImageAsDataUri(gethostname(), $secret);
echo $secret . "-" . $qrcode;