Rudimentary implementation of authentication processflow

This commit is contained in:
djpbessems
2019-01-23 22:08:30 +01:00
parent afd134659b
commit b04b2fb480
6 changed files with 71 additions and 20 deletions

View File

@ -3,13 +3,23 @@
include_once('../include/lucidAuth.functions.php');
echo $settings->Debug['Verbose'];
if ($_POST['do'] == 'login') {
$result = authenticateLDAP($_POST['username'], $_POST['password']);
if ($result['status'] == 'Success') {
// Convert base64 encoded string back from JSON;
// forcing it into an associative array (instead of javascript's default StdClass object)
try {
$proxyHeaders = json_decode(base64_decode($_POST['ref']), JSON_OBJECT_AS_ARRAY);
}
catch (Exception $e) {
// Since this request is only ever called through an AJAX-request; return JSON object
echo '{"Result":"Fail","Reason":"Original request URI lost in transition"}' . PHP_EOL;
exit;
}
$originalUri = $proxyHeaders['XForwardedProto'] . '://' . $proxyHeaders['XForwardedHost'] . $proxyHeaders['XForwardedUri'];
// Since this request is only ever called through an AJAX-request; return JSON object
echo '{"Result":"Success","Location":"<originalurl>"}' . PHP_EOL;
echo '{"Result":"Success","Location":"' . $originalUri . '"}' . PHP_EOL;
} else {
switch ($result['reason']) {
case '1':