-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfusionauthconnector.php
More file actions
62 lines (48 loc) · 1.3 KB
/
fusionauthconnector.php
File metadata and controls
62 lines (48 loc) · 1.3 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require __DIR__. '/config.php';
require __DIR__. '/common.php';
require __DIR__ . '/vendor/autoload.php';
use Ramsey\Uuid\Uuid;
$headers = getallheaders();
if (!$headers) {
error_log("Invalid authorization header.");
return;
}
// check auth header
$authorization_value = $headers['Authorization'];
if ($authorization_value !== $authorization_header_value) {
error_log("Invalid authorization header value found: ".$authorization_value);
return;
}
$input = file_get_contents('php://input');
$inputobj = json_decode($input);
if (!$inputobj) {
error_log("Invalid JSON");
return;
}
// for debugging the data passed to us
// error_log(var_export($input, TRUE));
if (!auth($inputobj->loginId, $inputobj->password)) {
http_response_code(404);
return;
}
// build the user object
// in the real world, we'd pull this from the database.
$obj = [];
$user = [];
$user['id'] = Uuid::uuid4();
$user['email'] = $inputobj->loginId;
$user['active'] = true;
$user['verified'] = true;
$data = [];
$data['favoriteColor'] = 'blue';
$data['migratedFromTheAtmDatastore'] = true;
$user['data'] = $data;
$registrations = [];
$registration = [];
$registration['applicationId'] = $client_id;
array_push($registrations, $registration);
$user['registrations'] = $registrations;
$obj['user'] = $user;
echo json_encode($obj);
?>