Fix base32 Encoding usage

This commit is contained in:
Bubka 2020-11-17 21:27:44 +01:00
parent 55ec97e332
commit 03981bc12b
3 changed files with 5 additions and 5 deletions

View File

@ -4,10 +4,8 @@
use App\Group;
use App\TwoFAccount;
use App\Classes\OTP;
use App\Classes\Options;
use Illuminate\Http\Request;
use ParagonIE\ConstantTime\Base32;
use Illuminate\Support\Facades\Storage;
class TwoFAccountController extends Controller
@ -19,7 +17,7 @@ class TwoFAccountController extends Controller
*/
public function index()
{
return response()->json(TwoFAccount::ofGroup(Options::get('activeGroup'))->ordered()->get()->toArray());
return response()->json(TwoFAccount::all());
}

View File

@ -7,6 +7,7 @@
use OTPHP\HOTP;
use OTPHP\Factory;
use App\Classes\Options;
use ParagonIE\ConstantTime\Base32;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;
use Illuminate\Database\Eloquent\Model;
@ -283,7 +284,7 @@ public function populate(Array $attrib = [])
try {
// Create an OTP object using our secret but with default parameters
$secret = $attrib['secretIsBase32Encoded'] === 1 ? $attrib['secret'] : Encoding::base32EncodeUpper($attrib['secret']);
$secret = $attrib['secretIsBase32Encoded'] === 1 ? $attrib['secret'] : Base32::encodeUpper($attrib['secret']);
$this->otp = $attrib['otpType'] === 'totp' ? TOTP::create($secret) : HOTP::create($secret);

View File

@ -4,6 +4,7 @@
use App\TwoFAccount;
use Faker\Generator as Faker;
use ParagonIE\ConstantTime\Base32;
/*
|--------------------------------------------------------------------------
@ -25,7 +26,7 @@
return [
'service' => $service,
'account' => $account,
'uri' => 'otpauth://totp/' . $service . ':' . $account . '?secret=' . $faker->regexify('[A-Z0-9]{16}') . '&issuer=' . $service,
'uri' => 'otpauth://totp/' . $service . ':' . $account . '?secret=' . Base32::encodeUpper($faker->regexify('[A-Z0-9]{8}')) . '&issuer=' . $service,
'icon' => '',
];
});