Enforced API security

This commit is contained in:
Pierre
2017-06-13 11:01:36 +02:00
parent 3729b56ff4
commit 4bbe967e2e
3 changed files with 67 additions and 7 deletions

View File

@ -17,11 +17,15 @@ class Tokens{
return false; //No token specified
//Check tokens
if(!$serviceID = $this->validateClientTokens($_POST['serviceName'], $_POST['serviceToken']))
if(!$serviceInfos = $this->validateClientTokens($_POST['serviceName'], $_POST['serviceToken']))
return false;
//Save service ID in a constant
define("APIServiceID", $serviceID);
define("APIServiceID", $serviceInfos["ID"]);
//Save service domain in a constant (if any)
if($serviceInfos["clientDomain"])
define("APIServiceDomain", $serviceInfos["clientDomain"]);
//Else everything went good
return true;
@ -52,7 +56,14 @@ class Tokens{
}
else {
//The API is correctly identified
return $requestResult[0]['ID'];
//Generate client informations
$clientInformations = array(
"ID" => $requestResult[0]['ID'],
"clientDomain" => ($requestResult[0]["client_domain"] == "" ? false : $requestResult[0]["client_domain"])
);
//Return API informations
return $clientInformations;
}
}