From 3078c0501a8aad70852ea794990e6eef985c4a59 Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Wed, 28 Feb 2024 16:28:44 -0700 Subject: [PATCH] Fixed syntax, other errors --- src/Hash/BuiltinHash.php | 3 ++- src/HashConfig.php | 4 ++-- src/Logger/Base.php | 20 +++++++++++--------- src/Workflow/UserManagement.php | 21 ++++++++++----------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/Hash/BuiltinHash.php b/src/Hash/BuiltinHash.php index 3dbd657..d0a928c 100644 --- a/src/Hash/BuiltinHash.php +++ b/src/Hash/BuiltinHash.php @@ -1,6 +1,7 @@ hashName, \hash_hmac_algos())) ? : throw \ValueError( + (\array_search(\strtolower($this->hashName), \hash_hmac_algos())) ? : throw new \ValueError( $this->hashName . " is not the name of a built-in hash function"); } diff --git a/src/HashConfig.php b/src/HashConfig.php index d2a1758..2254a1e 100644 --- a/src/HashConfig.php +++ b/src/HashConfig.php @@ -20,9 +20,9 @@ class HashConfig public int $digits=6 ) { - if (\is_string($this->hash)) + if (\is_string($this->algorithm)) { - $this->hash = new BuiltinHash($this->hash); + $this->algorithm = new BuiltinHash($this->algorithm); } } diff --git a/src/Logger/Base.php b/src/Logger/Base.php index a4d4a0e..3ebd354 100644 --- a/src/Logger/Base.php +++ b/src/Logger/Base.php @@ -1,51 +1,53 @@
"; - $html .= $this->moduleConfig.csrf->emitStr(); + $html .= $this->moduleConfig->csrf->emitStr(); $html .= "

To add an authenticator to your account, scan the QR code

"; $html .= "\"qr-code\""; $html .= ""; @@ -45,14 +45,14 @@ class UserManagement implements WorkflowInterface $otpauthURI = new Otpauth( $this->db->userString($this->userIndex), "taaatp", - $this->hashConfig.hash->keygen(), - $this->hashConfig.hash->hashType(), + $this->hashConfig->algorithm->keygen(), + $this->hashConfig->algorithm->hashType(), 6, 30 ); $provisioningUri = $otpauthURI->uriString(); $persistentUri = $otpauthURI->uriStringExplicit(); - $this->moduleConfig.session->store("secret", $persistentUri); + $this->moduleConfig->session->store("secret", $persistentUri); $values = [ "%frm" => $this->request->formProps("enroll"), @@ -64,7 +64,7 @@ class UserManagement implements WorkflowInterface private function viewUnenrollForm(): string { $html = "
"; - $html .= $this->moduleConfig.csrf->emitStr(); + $html .= $this->moduleConfig->csrf->emitStr(); $html .= ""; $html .= ""; $html .= ""; @@ -88,17 +88,16 @@ class UserManagement implements WorkflowInterface function response(): bool { - if (!$this->moduleConfig.csrf->match()) + if (!$this->moduleConfig->csrf->match()) { return false; } $pUri = $this->db->getSecret($this->userIndex); $enrollFlag = \is_null($pUri); - $enrollFlag && $pUri = $this->moduleConfig.session->get('secret'); - - echo "Recovered pURI for a " . ($enrollFlag)?"new user":"returning user"; + $enrollFlag && $pUri = $this->moduleConfig->session->get('secret'); + $this->moduleConfig->logger->info("Recovered pURI for a " . ($enrollFlag)?"new user":"returning user"); $totp = _6238( $pUri->getSecret(), @@ -106,8 +105,8 @@ class UserManagement implements WorkflowInterface $enrollFlag? 0:$this->db->getLastTime($this->userIndex), 2, $pUri.digits, - $this->hashConfig.clock, - $this->hashConfig.algorithm + $this->hashConfig->clock, + $this->hashConfig->algorithm ); $flag = $totp.validate($this->request->getResp("totp_challenge"));