Added conversion for user index to string

master
Brady McDonough 2 years ago
parent ea4731777e
commit fa50546a34

@ -1,7 +1,5 @@
- Better customization of the TOTP algorithm. Currently everything is just Google Authenticator's defaults. - 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 - 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` - 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 - The hash fed into the `_6238` object should be based on the hash referenced in the provisioning uri
-

@ -10,6 +10,13 @@ namespace BradyMcD\TAATP\Required;
*/ */
interface PersistenceInterface 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. * 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 * @param mixed $index Whatever data needed to index into your database and identify a particular user

@ -11,7 +11,7 @@ use BradyMcD\RFC\_6238;
use Chillerlan\QRCode; use Chillerlan\QRCode;
/** @SuppressWarnings(PHPMD.ShortVariable)*/
class UserManagement implements WorkflowInterface class UserManagement implements WorkflowInterface
{ {
public function __construct( public function __construct(
@ -43,7 +43,7 @@ class UserManagement implements WorkflowInterface
$provisioningUri = (new Otpauth( $provisioningUri = (new Otpauth(
"taatp", "taatp",
$this->userIndex, $this->db->userString($this->userIndex),
$this->hash->keygen(), $this->hash->keygen(),
"SHA1", "SHA1",
30, 30,

@ -4,7 +4,6 @@ use PHPUnit\Framework\TestCase;
use BradyMcD\TAATP\AntiCSRF\Base as BaseAntiCSRF; use BradyMcD\TAATP\AntiCSRF\Base as BaseAntiCSRF;
use BradyMcD\TAATP\Session\Base as BaseSession; use BradyMcD\TAATP\Session\Base as BaseSession;
use DateTimeImmutable;
final class TestClock implements \Psr\Clock\ClockInterface final class TestClock implements \Psr\Clock\ClockInterface
{ {
@ -20,9 +19,10 @@ final class TestClock implements \Psr\Clock\ClockInterface
self::$time = $time; 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); self::$clock->setTime(self::$clock->now()->getTimestamp() + 3600);
$this->assertFalse(self::$AntiCSRF->match()); $this->assertFalse(self::$antiCSRF->match());
} }
} }

Loading…
Cancel
Save