diff --git a/TODOS.md b/TODOS.md index caf35e2..5e8be54 100644 --- a/TODOS.md +++ b/TODOS.md @@ -1,7 +1,5 @@ - Better customization of the TOTP algorithm. Currently everything is just Google Authenticator's defaults. - - User indexing is assumed to be a string in the provisioning uri - Display is awful to code an open ended interface for, but I still should - Error reporting should be enhanced, either through a messaging object or via `throw` - The hash fed into the `_6238` object should be based on the hash referenced in the provisioning uri - - diff --git a/src/Required/PersistenceInterface.php b/src/Required/PersistenceInterface.php index 6807f61..ed23e12 100644 --- a/src/Required/PersistenceInterface.php +++ b/src/Required/PersistenceInterface.php @@ -10,6 +10,13 @@ namespace BradyMcD\TAATP\Required; */ interface PersistenceInterface { + /** + * Takes user indexing data and returns a string suitable for tagging and human readable info strings. + * @param mixed $index Whatever data needed to index info your database and identify a particular user + * @return string + */ + public function userString(mixed $index): string; + /** * Stores the otpauth URI for the user associated with the given indexing data. * @param mixed $index Whatever data needed to index into your database and identify a particular user diff --git a/src/Workflow/UserManagement.php b/src/Workflow/UserManagement.php index e2b9733..9606245 100644 --- a/src/Workflow/UserManagement.php +++ b/src/Workflow/UserManagement.php @@ -11,7 +11,7 @@ use BradyMcD\RFC\_6238; use Chillerlan\QRCode; - +/** @SuppressWarnings(PHPMD.ShortVariable)*/ class UserManagement implements WorkflowInterface { public function __construct( @@ -43,7 +43,7 @@ class UserManagement implements WorkflowInterface $provisioningUri = (new Otpauth( "taatp", - $this->userIndex, + $this->db->userString($this->userIndex), $this->hash->keygen(), "SHA1", 30, diff --git a/tests/AntiCSRFTest.php b/tests/AntiCSRFTest.php index fad572c..f387586 100644 --- a/tests/AntiCSRFTest.php +++ b/tests/AntiCSRFTest.php @@ -4,7 +4,6 @@ use PHPUnit\Framework\TestCase; use BradyMcD\TAATP\AntiCSRF\Base as BaseAntiCSRF; use BradyMcD\TAATP\Session\Base as BaseSession; -use DateTimeImmutable; final class TestClock implements \Psr\Clock\ClockInterface { @@ -20,9 +19,10 @@ final class TestClock implements \Psr\Clock\ClockInterface self::$time = $time; } - function now(): DateTimeImmutable + /** @SuppressWarnings(PHPMD.MissingImport) */ + function now(): \DateTimeImmutable { - return (new DateTimeImmutable())->setTimestamp(self::$time); + return (new \DateTimeImmutable())->setTimestamp(self::$time); } } @@ -80,7 +80,7 @@ final class AntiCSRFTest extends TestCase { self::$clock->setTime(self::$clock->now()->getTimestamp() + 3600); - $this->assertFalse(self::$AntiCSRF->match()); + $this->assertFalse(self::$antiCSRF->match()); } }