You are here

function bakery_bake_data in Bakery Single Sign-On System 7.4

Same name and namespace in other branches
  1. 6.2 bakery.module \bakery_bake_data()
  2. 7.2 bakery.module \bakery_bake_data()

Sign data for Bakery transfer.

Parameters

string $username: The Drupal username.

string $type: The cookie type (e.g. 'CHOCOLATECHIP').

int $expiration: Unix timestamp for the cookie expiration.

Array $claims: (Optional) list of claims of data to be transferred.

Return value

String of signed data, URL safe.

4 calls to bakery_bake_data()
bakery_profile_eat_gingerbread_cookie in ./bakery_profile.module
Respond with account information.
bakery_profile_request_account in ./bakery_profile.module
Request account information from master to create account locally.
bakery_profile_user_update in ./bakery_profile.module
Implements hook_user_update().
_bakery_bake_chocolatechip_cookie in ./bakery.module
Create a new cookie for identification

File

./bakery.module, line 397

Code

function bakery_bake_data($username, $type, $expiration, $claims = array()) {
  $key = variable_get('bakery_key', '');
  $uri = _bakery_uri();
  $now = REQUEST_TIME;
  $builder = new Builder();
  $builder
    ->setId($username, true)
    ->setIssuer($uri)
    ->setAudience($uri)
    ->setIssuedAt($now)
    ->setNotBefore($now - 60)
    ->setExpiration($expiration)
    ->set('type', $type);

  // Add additional claims.
  foreach ($claims as $name => $value) {
    $builder
      ->set($name, $value);
  }
  $builder
    ->sign(_bakery_signer(), $key);
  return (string) $builder
    ->getToken();
}