mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-11-15 21:00:14 +00:00
fix(web): post WebAuthn TFA enrollment through the JSON API
The forced TFA enrollment form submitted the raw credential JSON in the 'token' field, which set_tfa()'s webauthn case never reads. It expects the parsed \['registration'] object that only the JSON API builds, so the form POST inserted a row with an empty keyHandle and a NULL publicKey while still reporting success. Every WebAuthn 2FA login then failed, because webauthn-tfa-get-args sent an empty credential id in allowCredentials. - base.twig: POST the attestation to /api/v1/add/webauthn-tfa-registration like the regular WebAuthn modal does - functions.inc.php: refuse incomplete WebAuthn registrations - lang.en-gb.json: message for the new guard
This commit is contained in:
1 parent
8cd231c9b9
commit
d93f32072e
3 files changed
+30
-11
No files matched your search
@@ -1389,6 +1389,18 @@ function set_tfa($_data) {
|
||||
case "webauthn":
|
||||
$key_id = (!isset($_data["key_id"])) ? 'unidentified' : $_data["key_id"];
|
||||
|
||||
// Refuse incomplete WebAuthn registrations. Without this guard a request
|
||||
// that does not contain the parsed credential data (e.g. a plain form
|
||||
// POST) would silently insert an empty keyHandle while reporting success.
|
||||
if (empty($_data['registration']) || empty($_data['registration']->credentialId)) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
'log' => array(__FUNCTION__, $_data_log),
|
||||
'msg' => 'webauthn_registration_failed'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO `tfa` (`username`, `key_id`, `authmech`, `keyHandle`, `publicKey`, `certificate`, `counter`, `active`)
|
||||
VALUES (?, ?, 'webauthn', ?, ?, ?, ?, '1')");
|
||||
$stmt->execute(array(
|
||||
|
||||
Reference in new issue
Block a user