Update dependencies

This commit is contained in:
ErickSkrauch
2019-12-13 20:02:58 +03:00
parent 40eca5b8b6
commit 26f7d6213f
8 changed files with 708 additions and 1107 deletions

View File

@@ -1,12 +1,12 @@
namespace: api\tests
actor_suffix: Tester
bootstrap: _bootstrap.php
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
coverage:

View File

@@ -1,20 +0,0 @@
<?php
namespace api\modules\accounts\models;
use common\models\Account;
use OTPHP\TOTP;
trait TotpHelper {
abstract public function getAccount(): Account;
protected function getTotp(): TOTP {
$account = $this->getAccount();
$totp = TOTP::create($account->otp_secret);
$totp->setLabel($account->email);
$totp->setIssuer('Ely.by');
return $totp;
}
}

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace api\modules\accounts\models;
use api\exceptions\ThisShouldNotHappenException;
@@ -9,10 +11,11 @@ use BaconQrCode\Renderer\Color\Rgb;
use BaconQrCode\Renderer\Image\Svg;
use BaconQrCode\Writer;
use common\components\Qr\ElyDecorator;
use OTPHP\TOTP;
use OTPHP\TOTPInterface;
use ParagonIE\ConstantTime\Base32;
class TwoFactorAuthInfo extends BaseAccountForm {
use TotpHelper;
public function getCredentials(): array {
if (empty($this->getAccount()->otp_secret)) {
@@ -28,6 +31,15 @@ class TwoFactorAuthInfo extends BaseAccountForm {
];
}
private function getTotp(): TOTPInterface {
$account = $this->getAccount();
$totp = TOTP::create($account->otp_secret);
$totp->setLabel($account->email);
$totp->setIssuer('Ely.by');
return $totp;
}
private function drawQrCode(string $content): string {
$content = $this->forceMinimalQrContentLength($content);
@@ -89,7 +101,7 @@ class TwoFactorAuthInfo extends BaseAccountForm {
* @return string
*/
private function generateOtpSecret(int $length): string {
$randomBytesLength = ceil($length / 1.6);
$randomBytesLength = (int)ceil($length / 1.6);
$result = '';
while (strlen($result) < $length) {
/** @noinspection PhpUnhandledExceptionInspection */