Add WebAuthn integration, reCAPTCHA support, and new tests

- Integrate WebAuthn library for passkey authentication workflows, including assertion verification and improved error handling.
- Add support for reCAPTCHA token validation across multiple endpoints for enhanced security.
- Extend OpenAPI schema to document new fields and restructured payloads.
- Add unit tests for WebAuthn flows, permission initialization, and route validation to ensure robustness and accuracy.
This commit is contained in:
Jeppe Bundgaard
2026-02-24 09:27:51 +01:00
parent 2e88ed7bbd
commit b291e959e0
11 changed files with 2487 additions and 115 deletions
+22
View File
@@ -29,6 +29,28 @@ class passkeys_o extends db
$this->setTable('passkeys');
}
/**
* Finds a passkey by its credential ID, optionally constrained to a given user ID.
* Returns the selected object instance on success or null if not found.
*/
public function findByCredentialId(string $credentialId, ?int $userId = null): ?self
{
global $db;
$credentialId = $db->escape_string($credentialId);
$where = "credential_id = '" . $credentialId . "'";
if ($userId !== null) {
$where .= ' AND user_id = ' . (int)$userId;
}
$sql = "SELECT id FROM $this->table WHERE $where LIMIT 1";
$result = $db->query($sql);
$row = $db->fetch_assoc($result);
if (!$row || !isset($row['id'])) {
return null;
}
$this->select((int)$row['id']);
return $this;
}
/**
* Add a new passkey for a user
* @param int $user_id The customer number or subuser id, depending on the value of is_subuser