[GH-ISSUE #191] Secret key is too short. Must be at least 16 base32 characters #556

Closed
opened 2026-03-14 12:11:10 +03:00 by kerem · 7 comments
Owner

Originally created by @NaysKutzu on GitHub (Dec 8, 2023).
Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/191

<?php
require("requirements/page.php");

use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
use PragmaRX\Google2FA\Google2FA;
use MythicalClient\Handlers\ConfigHandler;

if ($session->getUserInfo("2fa_enabled") == "true") {
    header('location: /dashboard');
    die();
}

$google2fa = new Google2FA();
//Check if the key is in the database
if ($session->getUserInfo("2fa_secret") == null) {
    $secretKey = $google2fa->generateSecretKey(32);
    if (!$session->updateRowEncrypted($_COOKIE['token'], "2fa_secret", $secretKey)) {
        header('location: /dashboard?e=db_error');
        die();
    }
} else {
    $secretKey = $session->getUserInfoEncrypted("2fa_secret");
}

$g2faUrl = $google2fa->getQRCodeUrl(
    ConfigHandler::get('app', 'name'),
    $session->getUserInfoEncrypted("email"),
    $secretKey
);


$writer = new Writer(
    new ImageRenderer(
        new RendererStyle(400),
        new ImagickImageBackEnd()
    )
);
?>```
Originally created by @NaysKutzu on GitHub (Dec 8, 2023). Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/191 ```php <?php require("requirements/page.php"); use BaconQrCode\Renderer\Image\ImagickImageBackEnd; use BaconQrCode\Renderer\ImageRenderer; use BaconQrCode\Renderer\RendererStyle\RendererStyle; use BaconQrCode\Writer; use PragmaRX\Google2FA\Google2FA; use MythicalClient\Handlers\ConfigHandler; if ($session->getUserInfo("2fa_enabled") == "true") { header('location: /dashboard'); die(); } $google2fa = new Google2FA(); //Check if the key is in the database if ($session->getUserInfo("2fa_secret") == null) { $secretKey = $google2fa->generateSecretKey(32); if (!$session->updateRowEncrypted($_COOKIE['token'], "2fa_secret", $secretKey)) { header('location: /dashboard?e=db_error'); die(); } } else { $secretKey = $session->getUserInfoEncrypted("2fa_secret"); } $g2faUrl = $google2fa->getQRCodeUrl( ConfigHandler::get('app', 'name'), $session->getUserInfoEncrypted("email"), $secretKey ); $writer = new Writer( new ImageRenderer( new RendererStyle(400), new ImagickImageBackEnd() ) ); ?>```
kerem closed this issue 2026-03-14 12:11:16 +03:00
Author
Owner

@ainxgans commented on GitHub (Aug 28, 2025):

@NaysKutzu What is the solution

<!-- gh-comment-id:3232537358 --> @ainxgans commented on GitHub (Aug 28, 2025): @NaysKutzu What is the solution
Author
Owner

@NaysKutzu commented on GitHub (Aug 28, 2025):

I started to use another package for 2fa

<!-- gh-comment-id:3232674538 --> @NaysKutzu commented on GitHub (Aug 28, 2025): > I started to use another package for 2fa
Author
Owner

@ainxgans commented on GitHub (Sep 18, 2025):

@NaysKutzu withc one bro, give me the link

<!-- gh-comment-id:3305549045 --> @ainxgans commented on GitHub (Sep 18, 2025): @NaysKutzu withc one bro, give me the link
Author
Owner

@antonioribeiro commented on GitHub (Sep 18, 2025):

@NaysKutzu , the tests on your PR are failing, are you able to fix them? Did you run tests locally?

I understand your concern and even Google's but this package is being used on a huge number of applications, seeing it breaking them all is something we should avoid at all costs...

<!-- gh-comment-id:3306499060 --> @antonioribeiro commented on GitHub (Sep 18, 2025): @NaysKutzu , the tests on your PR are failing, are you able to fix them? Did you run tests locally? I understand your concern and even Google's but this package is being used on a huge number of applications, seeing it breaking them all is something we should avoid at all costs...
Author
Owner

@NaysKutzu commented on GitHub (Sep 18, 2025):

https://packagist.org/packages/pragmarx/google2fa

<!-- gh-comment-id:3309708719 --> @NaysKutzu commented on GitHub (Sep 18, 2025): https://packagist.org/packages/pragmarx/google2fa
Author
Owner

@NaysKutzu commented on GitHub (Sep 18, 2025):

and the issue is and can be related to your date or time not being in sync

<!-- gh-comment-id:3309711358 --> @NaysKutzu commented on GitHub (Sep 18, 2025): and the issue is and can be related to your date or time not being in sync
Author
Owner

@antonioribeiro commented on GitHub (Sep 19, 2025):

I just tagged v9.

<!-- gh-comment-id:3314126546 --> @antonioribeiro commented on GitHub (Sep 19, 2025): I just tagged v9.
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/google2fa#556
No description provided.