parent
9d7ff6c5f3
commit
8b2d419cbb
@ -0,0 +1,95 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace BradyMcD\TAATPExample;
|
||||
|
||||
require __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
use BradyMcD\TAATP\Factory;
|
||||
use BradyMcD\TAATP\Required\PersistenceInterface;
|
||||
use BradyMcD\TAATP\Request\Base as RequestRouter;
|
||||
use BradyMcD\TAATP\Session\Base as Session;
|
||||
use BradyMcD\TAATP\Workflow\UserManagement;
|
||||
|
||||
|
||||
class SessionPersistence implements PersistenceInterface
|
||||
{
|
||||
private Session $session;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->session = new Session();
|
||||
}
|
||||
|
||||
public function userString(mixed $index): string
|
||||
{
|
||||
assert(is_string($index));
|
||||
return $index;
|
||||
}
|
||||
|
||||
public function storeSecret(mixed $index, string $secret)
|
||||
{
|
||||
$userID = $this->userString($index) . "_URI";
|
||||
$this->session->store($userID, $secret);
|
||||
}
|
||||
|
||||
public function stripSecret(mixed $index)
|
||||
{
|
||||
$userID = $this->userString($index) . "_URI";
|
||||
$this->session->store($userID, null);
|
||||
}
|
||||
|
||||
public function storeLastTime(mixed $index, int $timestamp)
|
||||
{
|
||||
$userID = $this->userString($index) . "_timestamp";
|
||||
$this->session->store($userID, $timestamp);
|
||||
}
|
||||
|
||||
public function getSecret(mixed $index): ?string
|
||||
{
|
||||
$userID = $this->userString($index) . "_URI";
|
||||
return $this->session->get($userID);
|
||||
}
|
||||
|
||||
public function getLastTime(mixed $index): int
|
||||
{
|
||||
$userID = $this->userString($index) . "_timestamp";
|
||||
return $this->session->get($userID);
|
||||
}
|
||||
}
|
||||
|
||||
class HttpEnroll
|
||||
{
|
||||
private $totpFactory;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->totpFactory = new Factory(
|
||||
new SessionPersistence(),
|
||||
new RequestRouter("HttpFullFlow.php"),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
$this->userManagement = $this->totpFactory->userManagement("Testman@example.co");
|
||||
}
|
||||
|
||||
public function view()
|
||||
{
|
||||
$this->userManagement->view();
|
||||
}
|
||||
|
||||
public function response()
|
||||
{
|
||||
$this->userManagement->response();
|
||||
}
|
||||
}
|
||||
|
||||
$page = new HttpEnroll();
|
||||
|
||||
$page->response();
|
||||
$page->view();
|
||||
|
||||
?>
|
||||
Loading…
Reference in new issue