public static function MoAuthUtilities::callService in Google Authenticator / 2 Factor Authentication - 2FA 8.2
Same name and namespace in other branches
- 8 src/MoAuthUtilities.php \Drupal\miniorange_2fa\MoAuthUtilities::callService()
18 calls to MoAuthUtilities::callService()
- AuthenticationAPIHandler::challenge in src/
AuthenticationAPIHandler.php - AuthenticationAPIHandler::getAuthStatus in src/
AuthenticationAPIHandler.php - AuthenticationAPIHandler::getGoogleAuthSecret in src/
AuthenticationAPIHandler.php - AuthenticationAPIHandler::getRegistrationStatus in src/
AuthenticationAPIHandler.php - AuthenticationAPIHandler::register in src/
AuthenticationAPIHandler.php
File
- src/
MoAuthUtilities.php, line 489 - This file is part of miniOrange 2FA module.
Class
Namespace
Drupal\miniorange_2faCode
public static function callService($customer_id, $apiKey, $url, $json, $redirect_to_error_page = true) {
if (!self::isCurlInstalled()) {
if (!$redirect_to_error_page) {
return (object) array(
"status" => 'CURL_ERROR',
"message" => 'PHP cURL extension is not installed or disabled.',
);
}
self::showErrorMessage("cURL Error", "", "PHP cURL extension is not installed or disabled.");
}
$current_time_in_millis = round(microtime(TRUE) * 1000);
$string_to_hash = $customer_id . number_format($current_time_in_millis, 0, '', '') . $apiKey;
$hash_value = hash("sha512", $string_to_hash);
$moHeaders = array(
"Content-Type" => "application/json",
"Customer-Key" => $customer_id,
"Timestamp" => number_format($current_time_in_millis, 0, '', ''),
"Authorization" => $hash_value,
);
$response = \Drupal::httpClient()
->post($url, [
'body' => $json,
'http_errors' => FALSE,
'headers' => $moHeaders,
'verify' => false,
]);
return json_decode($response
->getBody());
}