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