secret.php 591 B

123456789101112131415161718
  1. <?php
  2. session_start();
  3. if (isset($_SESSION["userContext"]) === false && php_sapi_name() !== "cli") {
  4. exit();
  5. }
  6. require_once "/usr/local/hestia/web/inc/2fa/loader.php";
  7. Loader::register("./", "RobThree\\Auth");
  8. use RobThree\Auth\TwoFactorAuth;
  9. $tfa = new TwoFactorAuth("Hestia Control Panel");
  10. $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)
  11. $qrcode = $tfa->getQRCodeImageAsDataUri(gethostname(), $secret);
  12. echo $secret . "-" . $qrcode;