public function SearchSubscriber::calculateAuthCookie in Acquia Search 3.x
Same name and namespace in other branches
- 2.x src/EventSubscriber/SearchSubscriber.php \Drupal\acquia_search\EventSubscriber\SearchSubscriber::calculateAuthCookie()
Creates an authenticator based on a data string and HMAC-SHA1.
Parameters
string $string: Data string.
string $nonce: Nonce.
string $derived_key: Derived key.
string $env_id: Environment Id.
Return value
string Auth cookie string.
1 call to SearchSubscriber::calculateAuthCookie()
- SearchSubscriber::preExecuteRequest in src/
EventSubscriber/ SearchSubscriber.php - Build Acquia Search Solr Authenticator.
File
- src/
EventSubscriber/ SearchSubscriber.php, line 280
Class
- SearchSubscriber
- Class SearchSubscriber.
Namespace
Drupal\acquia_search\EventSubscriberCode
public function calculateAuthCookie($string, $nonce, $derived_key = NULL, $env_id = NULL) {
if (empty($derived_key)) {
$derived_key = $this
->getDerivedKey($env_id);
}
if (empty($derived_key)) {
// Expired or invalid subscription - don't continue.
return '';
}
$time = time();
$hmac = hash_hmac('sha1', $time . $nonce . $string, $derived_key);
return sprintf('acquia_solr_time=%s; acquia_solr_nonce=%s; acquia_solr_hmac=%s;', $time, $nonce, $hmac);
}