From 45b999b000925bcc4785d680e3b1fa87dd7182c9 Mon Sep 17 00:00:00 2001 From: LeinadAlberto Date: Fri, 23 Feb 2024 13:07:37 -0400 Subject: [PATCH 1/3] build: updated dependencies --- composer.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/composer.lock b/composer.lock index 9201ec2..e25a80e 100644 --- a/composer.lock +++ b/composer.lock @@ -300,16 +300,16 @@ "packages-dev": [ { "name": "lion/test", - "version": "v1.4.0", + "version": "v1.5.0", "source": { "type": "git", - "url": "https://github.com/lion-packages/test.git", - "reference": "c0eed0c33478b27a521258c94b053dd68d8e7bbc" + "url": "https://github.com/Sleon4/test.git", + "reference": "b087d55b4a18eb4e50afe52d4a747122e7d9f933" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lion-packages/test/zipball/c0eed0c33478b27a521258c94b053dd68d8e7bbc", - "reference": "c0eed0c33478b27a521258c94b053dd68d8e7bbc", + "url": "https://api.github.com/repos/Sleon4/test/zipball/b087d55b4a18eb4e50afe52d4a747122e7d9f933", + "reference": "b087d55b4a18eb4e50afe52d4a747122e7d9f933", "shasum": "" }, "require": { @@ -330,10 +330,10 @@ ], "description": "library to implement testing with helpers that allow easy testing with PHPUnit", "support": { - "issues": "https://github.com/lion-packages/test/issues", - "source": "https://github.com/lion-packages/test/tree/v1.4.0" + "issues": "https://github.com/Sleon4/test/issues", + "source": "https://github.com/Sleon4/test/tree/v1.5.0" }, - "time": "2024-01-09T14:44:37+00:00" + "time": "2024-02-13T21:08:53+00:00" }, { "name": "myclabs/deep-copy", @@ -396,16 +396,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.0.0", + "version": "v5.0.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc" + "reference": "2218c2252c874a4624ab2f613d86ac32d227bc69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4a21235f7e56e713259a6f76bf4b5ea08502b9dc", - "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/2218c2252c874a4624ab2f613d86ac32d227bc69", + "reference": "2218c2252c874a4624ab2f613d86ac32d227bc69", "shasum": "" }, "require": { @@ -448,9 +448,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.1" }, - "time": "2024-01-07T17:17:35+00:00" + "time": "2024-02-21T19:24:10+00:00" }, { "name": "phar-io/manifest", @@ -886,16 +886,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.8", + "version": "10.5.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "08f4fa74d5fbfff1ef22abffee47aaedcaea227e" + "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/08f4fa74d5fbfff1ef22abffee47aaedcaea227e", - "reference": "08f4fa74d5fbfff1ef22abffee47aaedcaea227e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50b8e314b6d0dd06521dc31d1abffa73f25f850c", + "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c", "shasum": "" }, "require": { @@ -967,7 +967,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.8" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.10" }, "funding": [ { @@ -983,7 +983,7 @@ "type": "tidelift" } ], - "time": "2024-01-19T07:07:27+00:00" + "time": "2024-02-04T09:07:51+00:00" }, { "name": "sebastian/cli-parser", From 6fd63305b0bad89c2de79689e96fba94cfaf4234 Mon Sep 17 00:00:00 2001 From: LeinadAlberto Date: Wed, 28 Feb 2024 23:19:42 -0400 Subject: [PATCH 2/3] docs: classes, methods and properties have been documented --- src/LionAuthentication/Auth2FA.php | 41 +++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/LionAuthentication/Auth2FA.php b/src/LionAuthentication/Auth2FA.php index 7b3c947..800812f 100644 --- a/src/LionAuthentication/Auth2FA.php +++ b/src/LionAuthentication/Auth2FA.php @@ -6,24 +6,49 @@ use PragmaRX\Google2FAQRCode\Google2FA; +/** + * Provides functionality for two-factor authentication (2FA) using Google + * Authenticator + * + * @package Lion\Authentication + */ class Auth2FA { + /** + * [Google2FA class object] + * + * @var Google2FA $google2FA + */ private Google2FA $google2FA; + /** + * Class constructor + */ public function __construct() { $this->google2FA = new Google2FA(); } + /** + * Generates a QR code for two-factor authentication (2FA) + * + * @param string $companyName [The name of the company] + * @param string $companyEmail [The company email] + * @param int $size [The desired size for the QR code] + * @param string $encoding [Text encoding] + * @param int $length [The length of the secret key] + * @param string $prefix [The optional prefix for the secret key] + * + * @return object + */ public function qr( string $companyName, string $companyEmail, int $size = 200, string $encoding = 'utf-8', int $length = 16, - string $prefix = '', - ): object - { + string $prefix = '' + ): object { $secretKey = $this->google2FA->generateSecretKey($length, $prefix); $img = base64_encode( @@ -41,6 +66,16 @@ public function qr( ]; } + /** + * Verifies the authenticity of a given secret code, relative to a given + * secret key + * + * @param string $secretKey [The secret key used to generate the QR code] + * @param string $secretCode [The secret code entered by the user for + * authentication] + * + * @return object + */ public function verify(string $secretKey, string $secretCode): object { $validation = (bool) $this->google2FA->verifyKey($secretKey, $secretCode); From 51ef70b842f11c2ead4a0df3efbd20c18681ccc3 Mon Sep 17 00:00:00 2001 From: Sleon4 Date: Thu, 29 Feb 2024 09:38:51 -0500 Subject: [PATCH 3/3] chore: constants have been removed --- README.md | 1 + api.php | 2 +- composer.lock | 12 ++++++------ index.php | 2 +- tests/Auth2FATest.php | 6 +++--- tests/Constanst.php | 1 - 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ac6d3c3..f6deb6a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@

## Install + ```bash composer require lion/authentication ``` diff --git a/api.php b/api.php index 21fdaed..0ef0830 100644 --- a/api.php +++ b/api.php @@ -4,7 +4,7 @@ header('Content-Type: application/json'); -use LionAuthentication\Auth2FA; +use Lion\Authentication\Auth2FA; $content = json_decode(file_get_contents("php://input"), true); $request = $content === null ? ((object) [...$_POST, ...$_GET]) : ((object) $content); diff --git a/composer.lock b/composer.lock index e25a80e..638439c 100644 --- a/composer.lock +++ b/composer.lock @@ -886,16 +886,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.10", + "version": "10.5.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c" + "reference": "0d968f6323deb3dbfeba5bfd4929b9415eb7a9a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50b8e314b6d0dd06521dc31d1abffa73f25f850c", - "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0d968f6323deb3dbfeba5bfd4929b9415eb7a9a4", + "reference": "0d968f6323deb3dbfeba5bfd4929b9415eb7a9a4", "shasum": "" }, "require": { @@ -967,7 +967,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.10" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.11" }, "funding": [ { @@ -983,7 +983,7 @@ "type": "tidelift" } ], - "time": "2024-02-04T09:07:51+00:00" + "time": "2024-02-25T14:05:00+00:00" }, { "name": "sebastian/cli-parser", diff --git a/index.php b/index.php index b142e9e..917b7bf 100644 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ require_once('./vendor/autoload.php'); -use LionAuthentication\Auth2FA; +use Lion\Authentication\Auth2FA; header('Content-Type: application/json'); diff --git a/tests/Auth2FATest.php b/tests/Auth2FATest.php index e8e18ec..ba60411 100644 --- a/tests/Auth2FATest.php +++ b/tests/Auth2FATest.php @@ -16,13 +16,13 @@ class Auth2FATest extends Test protected function setUp(): void { $this->auth2FA = new Auth2FA(); + + $this->initReflection($this->auth2FA); } public function testConstruct(): void { - $this->initReflection($this->auth2FA); - - $this->assertInstanceOf(Google2FA::class, $this->getPrivateProperty(Constanst::PROPIERTY)); + $this->assertInstanceOf(Google2FA::class, $this->getPrivateProperty('google2FA')); } public function testQr(): void diff --git a/tests/Constanst.php b/tests/Constanst.php index 872fc60..8d9538c 100644 --- a/tests/Constanst.php +++ b/tests/Constanst.php @@ -6,7 +6,6 @@ class Constanst { - const PROPIERTY = 'google2FA'; const STATUS = 'status'; const MESSAGE = 'message'; const DATA = 'data';