remove support for newest TOTP and QR libraries (they are not <= PHP 7.0 compatible)
This commit is contained in:
parent
2dde73ee61
commit
96057b594a
@ -2,7 +2,6 @@
|
||||
"name": "d3/totp",
|
||||
"description": "Two-factor authentication for OXID eSales shop",
|
||||
"type": "oxideshop-module",
|
||||
"version": "0.1",
|
||||
"keywords": [
|
||||
"oxid",
|
||||
"modules",
|
||||
@ -34,8 +33,8 @@
|
||||
"require": {
|
||||
"php": ">=5.6",
|
||||
"oxid-esales/oxideshop-metapackage-ce": "~6.0.3 || ~6.1.0",
|
||||
"spomky-labs/otphp": "^8.3 || ^9.0",
|
||||
"bacon/bacon-qr-code": "^1.0 || ^2.0"
|
||||
"spomky-labs/otphp": "^8.3",
|
||||
"bacon/bacon-qr-code": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -15,9 +15,7 @@
|
||||
|
||||
namespace D3\Totp\Application\Model;
|
||||
|
||||
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||
use BaconQrCode\Renderer\Image\Svg;
|
||||
use BaconQrCode\Writer;
|
||||
use D3\ModCfg\Application\Model\d3database;
|
||||
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
|
||||
@ -92,7 +90,6 @@ class d3totp extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
* @return bool
|
||||
*/
|
||||
public function UserUseTotp()
|
||||
@ -102,7 +99,6 @@ class d3totp extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
* @return string
|
||||
*/
|
||||
public function getSavedSecret()
|
||||
@ -128,39 +124,21 @@ class d3totp extends BaseModel
|
||||
{
|
||||
if (false == $this->totp) {
|
||||
|
||||
if ($this->getTotpLibVersion() == 8) { // version 0.8 (< PHP 7.1)
|
||||
$this->totp = oxNew(
|
||||
TOTP::class,
|
||||
$this->getUser()->getFieldData('oxusername')
|
||||
? $this->getUser()->getFieldData('oxusername')
|
||||
: null,
|
||||
$seed
|
||||
? $seed
|
||||
: $this->getSavedSecret()
|
||||
);
|
||||
} else { // version 0.9 (>= PHP 7.1)
|
||||
$this->totp = TOTP::create($seed ? $seed : $this->getSavedSecret());
|
||||
$this->totp->setLabel($this->getUser()->getFieldData('oxusername')
|
||||
$this->totp = oxNew(
|
||||
TOTP::class,
|
||||
$this->getUser()->getFieldData('oxusername')
|
||||
? $this->getUser()->getFieldData('oxusername')
|
||||
: ''
|
||||
);
|
||||
}
|
||||
: null,
|
||||
$seed
|
||||
? $seed
|
||||
: $this->getSavedSecret()
|
||||
);
|
||||
$this->totp->setIssuer(Registry::getConfig()->getActiveShop()->getFieldData('oxname'));
|
||||
}
|
||||
|
||||
return $this->totp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTotpLibVersion()
|
||||
{
|
||||
return method_exists(TOTP::class, 'create') ?
|
||||
9 :
|
||||
8;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -174,11 +152,10 @@ class d3totp extends BaseModel
|
||||
*/
|
||||
public function getQrCodeElement()
|
||||
{
|
||||
/** @var ImageRenderer $renderer */
|
||||
$renderer = oxNew(ImageRenderer::class,
|
||||
oxNew(RendererStyle::class, 200),
|
||||
oxNew(SvgImageBackEnd::class)
|
||||
);
|
||||
$renderer = oxNew(Svg::class);
|
||||
$renderer->setHeight(200);
|
||||
$renderer->setWidth(200);
|
||||
|
||||
/** @var Writer $writer */
|
||||
$writer = oxNew(Writer::class, $renderer);
|
||||
return $writer->writeString($this->getTotp()->getProvisioningUri());
|
||||
|
Loading…
Reference in New Issue
Block a user