private function AcquiaSearchApiClient::calculateAuthHeader in Acquia Search 3.x
Creates an authenticator based on a HMAC V2 signer.
Parameters
array $req_params: Request parameters.
string $authorization_string: Authorization string.
Return value
string Returns the signed auth header
1 call to AcquiaSearchApiClient::calculateAuthHeader()
- AcquiaSearchApiClient::searchRequest in src/
AcquiaSearchApiClient.php - Create and send a request to search controller.
File
- src/
AcquiaSearchApiClient.php, line 204
Class
- AcquiaSearchApiClient
- Acquia implementation of the Search API Client.
Namespace
Drupal\acquia_searchCode
private function calculateAuthHeader(array $req_params, string $authorization_string) : string {
$signature_base_string = implode("\n", $req_params);
$digest = hash_hmac('sha256', $signature_base_string, base64_decode($this->authInfo['key'], TRUE), TRUE);
$signature = base64_encode($digest);
$authorization_header_string = str_replace("=", "=\"", str_replace("&", "\",", $authorization_string));
return 'acquia-http-hmac ' . $authorization_header_string . '",signature="' . $signature . '"';
}