public function Kitchen::bakeData in Bakery Single Sign-On System 8.2
Encrypt and sign data for Bakery transfer.
Parameters
\Drupal\bakery\Cookies\CookieInterface $cookie: The cookie data.
Return value
string String of signed and encrypted data, url safe.
2 calls to Kitchen::bakeData()
- Kitchen::bake in src/
Kitchen.php - Set a cookie.
- Kitchen::ship in src/
Kitchen.php - Ship a cookie to child sites.
File
- src/
Kitchen.php, line 91
Class
Namespace
Drupal\bakeryCode
public function bakeData(CookieInterface $cookie) {
$key = $this->config
->get('bakery_key');
if (empty($key)) {
throw new MissingKeyException();
}
$data = $cookie
->toData();
$data['type'] = $cookie::getName();
$data['timestamp'] = $this->time
->getRequestTime();
$data = $this
->encrypt(serialize($data));
$signature = hash_hmac('sha256', $data, $key);
return base64_encode($signature . $data);
}