generated from Firehed/php-library-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreadmeLoginStep1.php
More file actions
30 lines (23 loc) · 690 Bytes
/
readmeLoginStep1.php
File metadata and controls
30 lines (23 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require __DIR__ . '/vendor/autoload.php';
use Firehed\WebAuthn\{
Codecs,
ExpiringChallenge,
};
session_start();
$pdo = getDatabaseConnection();
$user = getUserByName($pdo, $_POST['username']);
if ($user === null) {
header('HTTP/1.1 404 Not Found');
return;
}
$_SESSION['authenticating_user_id'] = $user['id'];
$credentialContainer = getCredentialsForUserId($pdo, $user['id']);
$challengeManager = getChallengeManager();
$challenge = $challengeManager->createChallenge();
// Send to user
header('Content-type: application/json');
echo json_encode([
'challengeB64' => $challenge->getBase64(),
'credential_ids' => $credentialContainer->getBase64Ids(),
]);