You are here

private function SearchApiAcquiaApi::calculateAuthHeader in Acquia Search for Search API 7.2

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 SearchApiAcquiaApi::calculateAuthHeader()
SearchApiAcquiaApi::getIndexes in includes/v3/SearchApiAcquiaApi.php
Returns list of search indexes.

File

includes/v3/SearchApiAcquiaApi.php, line 263

Class

SearchApiAcquiaApi
Class SearchApiAcquiaApi.

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;
}