1234567891011121314151617181920212223242526272829 |
- <?php
- // https://github.com/Spomky-Labs/otphp/blob/11.2.x/doc/index.md
- // https://www.youtube.com/watch?v=e-1Yh8iH8jk&ab_channel=Boris%28%27PrimFX%27%29
- // Documentation disponible ici : https://chillerlan.github.io/php-qrcode/
- // Format de création des code QR pour 2FA :
- // $data = 'otpauth://totp/liberations:user@gmail.com?secret=B3JX4VCVJDVNXNZ5&issuer=https://liberations.magikweb.ca/';
- // Get the token
- // -------------
- function getUser2faSecret() {
- // Random secret will be generated from this.
- $otp = OTPHP\TOTP::generate();
- //TODO Corriger l'adresse courriel
- //$otp->setLabel('alice@google.com');
- //echo "The OTP secret is: {$secret}<br>\n";
- //echo "The current OTP is: {$otp->now()}<br>\n";
- return $otp->getSecret(); // À inscrire dans la base de données
- }
- // Check the token
- // ---------------
- function check2fa($secret, $input) {
- $otp = OTPHP\TOTP::createFromSecret($secret); // create TOTP object from the secret.
- //TODO Corriger l'adresse courriel
- //$otp->setLabel('alice@google.com');
- return $otp->verify($input);
- }
|