private function AcquiaSearchSolrApi::calculateAuthHeader in Acquia Connector 7.3
Calculates authorization headers.
Parameters
string $key: API key.
array $params: Request parameters.
string $auth_string: Authorization string.
Return value
string Authorization header.
1 call to AcquiaSearchSolrApi::calculateAuthHeader()
- AcquiaSearchSolrApi::getIndexes in acquia_search/
includes/ AcquiaSearchSolrApi.php - Returns list of search indexes.
File
- acquia_search/
includes/ AcquiaSearchSolrApi.php, line 263
Class
- AcquiaSearchSolrApi
- Class AcquiaSearchApi.
Code
private function calculateAuthHeader($key, array $params, $auth_string) {
$auth_string = str_replace([
'&',
'=',
], [
'",',
'="',
], $auth_string);
$key = base64_decode($key, TRUE);
$signature_base_string = implode(PHP_EOL, $params);
$digest = hash_hmac('sha256', $signature_base_string, $key, TRUE);
$signature = base64_encode($digest);
$header = sprintf('acquia-http-hmac %s ",signature="%s"', $auth_string, $signature);
return $header;
}