|
|
|
|
@ -34,7 +34,7 @@ class UserManagement implements WorkflowInterface
|
|
|
|
|
private function viewEnrollForm(): string
|
|
|
|
|
{
|
|
|
|
|
$html = "<div id=\"enroll\"><form %frm>";
|
|
|
|
|
$html .= $this->moduleConfig.csrf->emitStr();
|
|
|
|
|
$html .= $this->moduleConfig->csrf->emitStr();
|
|
|
|
|
$html .= "<p>To add an authenticator to your account, scan the QR code</p>";
|
|
|
|
|
$html .= "<img src=%qr alt=\"qr-code\" height=256px width=256px/>";
|
|
|
|
|
$html .= "<label for=\"totp_challenge\">Enter the authentication code:</label>";
|
|
|
|
|
@ -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 = "<div id=\"unenroll\"><form %frm>";
|
|
|
|
|
$html .= $this->moduleConfig.csrf->emitStr();
|
|
|
|
|
$html .= $this->moduleConfig->csrf->emitStr();
|
|
|
|
|
$html .= "<label for=\"totp_challenge\">To de-register your authenticator enter the current authentication code:</label>";
|
|
|
|
|
$html .= "<intput name=\"totp_challenge\" id=\"totp_challenge\" type\"text\" />";
|
|
|
|
|
$html .= "<input type=\"submit\" value=\"Submit\" />";
|
|
|
|
|
@ -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"));
|
|
|
|
|
|
|
|
|
|
|