From 4b4176cc7baac188ba6375102843c1a51e5266fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C2=B3=20Data=20Development?= Date: Tue, 22 Dec 2020 09:33:38 +0100 Subject: [PATCH 1/4] Create README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..21e51c3 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# oxtotp +Modul für eine 2-Faktor-Authentisierung (2FA) zum Login in Front- und Backend zusätzlich zu Benutzername und Passwort. + +- Authentisierung wird nur bei Benutzerkonten gezeigt, die dieses aktiviert haben - sonst nur Standardanmeldung die Basis der Passwortgenerierung wird für jedes Benutzerkonto individuell angelegt + +- Einrichtung des Zugangs in der Auth-App kann durch scanbaren QR-Code oder kopierbare Zeichenkette erfolgen + +- Validierung der Einmalpassworte und Generierung der QR-Codes werden ausschließlich innerhalb des Shops durchgeführt - keine Kommunikation nach außen nötig + +- statische Backupcodes ermöglichen auch eine (begrenzte) Anmeldung ohne Zugang zum Generierungstool From 6e72394bc7835f605c8917aded1a41e47de07cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C2=B3=20Data=20Development?= Date: Tue, 22 Dec 2020 09:33:59 +0100 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21e51c3..7cc913c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# oxtotp +# oxtotp (2FA) Modul für eine 2-Faktor-Authentisierung (2FA) zum Login in Front- und Backend zusätzlich zu Benutzername und Passwort. - Authentisierung wird nur bei Benutzerkonten gezeigt, die dieses aktiviert haben - sonst nur Standardanmeldung die Basis der Passwortgenerierung wird für jedes Benutzerkonto individuell angelegt From 219427fb756e209424ce98a7a706bfbf07a17d4d Mon Sep 17 00:00:00 2001 From: Tobias Matthaiou Date: Mon, 12 Sep 2022 15:07:42 +0200 Subject: [PATCH 3/4] Autor und neuste version bacon/bacon-qr-code --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f59312c..da9e389 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,12 @@ "email": "info@shopmodule.com", "homepage": "http://www.d3data.de", "role": "Owner" + }, + { + "name": "Tobi Matthaiou", + "email": "tm@loberon.com", + "homepage": "http://www.loberon.de", + "role": "Contributor" } ], "support": { @@ -34,7 +40,7 @@ "php": ">=5.6", "oxid-esales/oxideshop-metapackage-ce": "~6.0.3 || ~6.1.0 || ~6.2.0", "spomky-labs/otphp": "^8.3", - "bacon/bacon-qr-code": "^1.0", + "bacon/bacon-qr-code": "^1.0 || ^2.0", "zendframework/zend-math": "^3.2" }, "autoload": { From 96f6de63006a936f8082917f6345b43183d0c7fb Mon Sep 17 00:00:00 2001 From: Tobias Matthaiou Date: Mon, 12 Sep 2022 15:16:14 +0200 Subject: [PATCH 4/4] The module is now compatible with all: - bacon/bacon-qr-code: ^1.0 || ^2.0 - oxid-esales/oxideshop-metapackage-ce: "~6.0.3 || ~6.1.0 || ~6.2.0 || ~6.3.0 || ~6.4.0 || ~6.5.0" --- composer.json | 103 +++++++++--------- .../Factory/BaconQrCodeFactory.php | 47 ++++++++ src/Application/Model/d3totp.php | 7 +- .../unit/Application/Model/d3totpTest.php | 14 +-- 4 files changed, 108 insertions(+), 63 deletions(-) create mode 100644 src/Application/Factory/BaconQrCodeFactory.php diff --git a/composer.json b/composer.json index da9e389..fbbf3c4 100644 --- a/composer.json +++ b/composer.json @@ -1,51 +1,52 @@ -{ - "name": "d3/oxtotp", - "description": "Two-factor authentication via time-based one-time password for OXID eSales shop", - "type": "oxideshop-module", - "keywords": [ - "oxid", - "modules", - "eShop", - "d3", - "2FA" - ], - "authors": [ - { - "name": "D3 Data Development (Inh. Thomas Dartsch)", - "email": "info@shopmodule.com", - "homepage": "http://www.d3data.de", - "role": "Owner" - }, - { - "name": "Tobi Matthaiou", - "email": "tm@loberon.com", - "homepage": "http://www.loberon.de", - "role": "Contributor" - } - ], - "support": { - "email": "support@shopmodule.com" - }, - "homepage": "https://www.oxidmodule.com/", - "license": [ - "GPL-3.0-only" - ], - "extra": { - "oxideshop": { - "source-directory": "/src", - "target-directory": "d3/totp" - } - }, - "require": { - "php": ">=5.6", - "oxid-esales/oxideshop-metapackage-ce": "~6.0.3 || ~6.1.0 || ~6.2.0", - "spomky-labs/otphp": "^8.3", - "bacon/bacon-qr-code": "^1.0 || ^2.0", - "zendframework/zend-math": "^3.2" - }, - "autoload": { - "psr-4": { - "D3\\Totp\\": "../../../source/modules/d3/totp" - } - } -} +{ + "name": "d3/oxtotp", + "description": "Two-factor authentication via time-based one-time password for OXID eSales shop", + "type": "oxideshop-module", + "keywords": [ + "oxid", + "modules", + "eShop", + "d3", + "2FA" + ], + "authors": [ + { + "name": "D3 Data Development (Inh. Thomas Dartsch)", + "email": "info@shopmodule.com", + "homepage": "http://www.d3data.de", + "role": "Owner" + }, + { + "name": "Tobi Matthaiou", + "email": "tm@loberon.com", + "homepage": "http://www.loberon.de", + "role": "Contributor" + } + ], + "support": { + "email": "support@shopmodule.com" + }, + "homepage": "https://www.oxidmodule.com/", + "license": [ + "GPL-3.0-only" + ], + "extra": { + "oxideshop": { + "source-directory": "/src", + "target-directory": "d3/totp" + } + }, + "require": { + "php": ">=5.6", + "ext-xmlwriter": "*", + "oxid-esales/oxideshop-metapackage-ce": "~6.0.3 || ~6.1.0 || ~6.2.0 || ~6.3.0 || ~6.4.0 || ~6.5.0", + "spomky-labs/otphp": "^8.3", + "bacon/bacon-qr-code": "^1.0 || ^2.0", + "zendframework/zend-math": "^3.2" + }, + "autoload": { + "psr-4": { + "D3\\Totp\\": "../../../source/modules/d3/totp" + } + } +} diff --git a/src/Application/Factory/BaconQrCodeFactory.php b/src/Application/Factory/BaconQrCodeFactory.php new file mode 100644 index 0000000..69808fe --- /dev/null +++ b/src/Application/Factory/BaconQrCodeFactory.php @@ -0,0 +1,47 @@ +setHeight($size); + $renderer->setWidth($size); + + return $renderer; + } +} diff --git a/src/Application/Model/d3totp.php b/src/Application/Model/d3totp.php index 4b35a4c..6630bec 100644 --- a/src/Application/Model/d3totp.php +++ b/src/Application/Model/d3totp.php @@ -15,9 +15,9 @@ namespace D3\Totp\Application\Model; -use BaconQrCode\Renderer\Image\Svg; use BaconQrCode\Renderer\RendererInterface; use BaconQrCode\Writer; +use D3\Totp\Application\Factory\BaconQrCodeFactory; use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException; use Doctrine\DBAL\DBALException; use OTPHP\TOTP; @@ -177,10 +177,7 @@ class d3totp extends BaseModel */ public function getQrCodeElement() { - $renderer = oxNew(Svg::class); - $renderer->setHeight(200); - $renderer->setWidth(200); - + $renderer = BaconQrCodeFactory::renderer(200); $writer = $this->d3GetWriter($renderer); return $writer->writeString($this->getTotp()->getProvisioningUri()); } diff --git a/src/tests/unit/Application/Model/d3totpTest.php b/src/tests/unit/Application/Model/d3totpTest.php index df22d25..a6fbde7 100644 --- a/src/tests/unit/Application/Model/d3totpTest.php +++ b/src/tests/unit/Application/Model/d3totpTest.php @@ -17,8 +17,8 @@ namespace D3\Totp\tests\unit\Application\Model; -use BaconQrCode\Renderer\Image\Svg; use BaconQrCode\Writer; +use D3\Totp\Application\Factory\BaconQrCodeFactory; use D3\Totp\Application\Model\d3backupcodelist; use D3\Totp\Application\Model\d3totp; use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException; @@ -484,7 +484,7 @@ class d3totpTest extends d3TotpUnitTestCase 'getFieldData', )); $oUserMock->method('getFieldData')->willReturn('username'); - + /** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oModelMock */ $oModelMock = $this->getMock(d3totp::class, array( 'getUser', @@ -544,7 +544,7 @@ class d3totpTest extends d3TotpUnitTestCase 'getQrCodeUri' )); $oTotpMock->expects($this->once())->method('getQrCodeUri')->willReturn(true); - + /** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oModelMock */ $oModelMock = $this->getMock(d3totp::class, array( 'getTotp' @@ -562,7 +562,7 @@ class d3totpTest extends d3TotpUnitTestCase */ public function getQrCodeElement() { - $renderer = oxNew(Svg::class); + $renderer = BaconQrCodeFactory::renderer(200); /** @var d3totp|PHPUnit_Framework_MockObject_MockObject $oTotpMock */ $oTotpMock = $this->getMock(d3totp::class, array( @@ -595,14 +595,14 @@ class d3totpTest extends d3TotpUnitTestCase */ public function d3GetWriterReturnsRightInstance() { - $renderer = oxNew(Svg::class); + $renderer = BaconQrCodeFactory::renderer(200);; $this->assertInstanceOf( Writer::class, $this->callMethod($this->_oModel, 'd3GetWriter', [$renderer]) ); } - + /** * @test * @throws ReflectionException @@ -878,4 +878,4 @@ class d3totpTest extends d3TotpUnitTestCase $this->callMethod($this->_oModel, 'delete') ); } -} \ No newline at end of file +}