get('otp'); $repository = new \Database(0); // remove old request (> 24 hours) $repository->exec_sql("delete from otp_send_secret where os_timestamp < now()-interval '24 hours'"); // check if UUID exist $id = $repository->get_value("select os_id from otp_send_secret where os_request=$1", [$uuid]); // if UUID doesn't exist exit if ($repository->count() == 0) { return; } // get email from id $otp_send = new Otp_Send_Secret_SQL($repository, $id); $user = new Noalyss_User($repository, $otp_send->get('use_id')); $secret = $user->get_otp_secret(); // OTP $options = new AuthenticatorOptions; $options->secret_length = 32; $options->algorithm = AuthenticatorInterface::ALGO_SHA512; $options->digits=6; $authenticator = new Authenticator($options); $authenticator->setSecret($secret); $data= $authenticator->getUri(label:"noalyss:".$user->getEmail(),issuer:"noalyss.eu"); // load secret for this id //echo "use with php -S localhost:5000 puis ouvrir index.html "; $writer = new PngWriter(); // Create QR code $qrCode = new QrCode( data: $data, encoding: new Encoding('UTF-8'), errorCorrectionLevel: ErrorCorrectionLevel::Medium, size: 600, margin: 10, roundBlockSizeMode: RoundBlockSizeMode::Margin, foregroundColor: new Color(0, 0, 0), backgroundColor: new Color(255, 255, 255) ); $result = $writer->write($qrCode); echo '
'; // generate the QRCode echo '

',_("Scanner ceci avec votre application OTP"),'

'; ?>
  1. FreeOTP (libre)
  2. AEgis Authenticator (libre)
  3. Google Authenticator
'; echo _("Scanner ce QRCode avec votre application OTP afin de l'ajouter"); if ( DEBUGNOALYSS > 1) { echo "code attendu",$authenticator->code();} echo '

'; printf('', base64_encode($result->getString())); } catch (Exception $exc) { record_log($e); return; } ?>