Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | require_once(__DIR__."/../core.php"); |
| 3 | |
| 4 | if (!secondFactor::isAvailable() || security::userType() !== security::UNKNOWN || !isset($_SESSION["firstfactorid"]) || !secondFactor::isEnabled($_SESSION["firstfactorid"]) || !secondFactor::hasSecurityKeys($_SESSION["firstfactorid"]) || $_SERVER['REQUEST_METHOD'] !== "POST") { |
| 5 | api::error(); |
| 6 | } |
| 7 | |
| 8 | $input = api::inputJson(); |
| 9 | if ($input === false || !isset($input["id"]) || !isset($input["clientDataJSON"]) || !isset($input["authenticatorData"]) || !isset($input["signature"])) api::error(); |
| 10 | $id = (string)$input["id"]; |
| 11 | $clientDataJSON = (string)$input["clientDataJSON"]; |
| 12 | $authenticatorData = (string)$input["authenticatorData"]; |
| 13 | $signature = (string)$input["signature"]; |
| 14 | |
| 15 | try { |
| 16 | $result = secondFactor::completeValidationChallenge($id, $clientDataJSON, $authenticatorData, $signature); |
| 17 | } catch (Throwable $e) { |
| 18 | api::error($conf['debug'] ? $e->getMessage() : null); |
| 19 | } |
| 20 | |
| 21 | api::write($result); |