/** * Generate the url for ID Site. * * @param array $options * @return string * @throws InvalidCallbackUriException */ public function createIdSiteUrl(array $options = array()) { if (!isset($options['callbackUri'])) { throw new InvalidCallbackUriException('Please provide a \'callbackUri\' in the $options array.'); } $p = parse_url($this->href); $base = $p['scheme'] . '://' . $p['host']; $apiId = $this->getDataStore()->getApiKey()->getId(); $apiSecret = $this->getDataStore()->getApiKey()->getSecret(); $token = array('jti' => UUID::v4(), 'iat' => microtime(true), 'iss' => $apiId, 'sub' => $this->href, 'state' => isset($options['state']) ? $options['state'] : '', 'path' => isset($options['path']) ? $options['path'] : '/', 'cb_uri' => $options['callbackUri']); if (isset($options['organizationNameKey'])) { $token['onk'] = $options['organizationNameKey']; } if (isset($options['showOrganizationField'])) { $token['sof'] = true; } if (isset($options['useSubDomain'])) { $token['usd'] = true; } $jwt = JWT::encode($token, $apiSecret); $redirectUrl = $base . "/sso"; if (isset($options['logout'])) { $redirectUrl .= "/logout"; } return $redirectUrl . "?jwtRequest={$jwt}"; }
public static function generateNonce() { return UUID::v4(); }
protected function generateResponseUrl() { $jwt = array(); $jwt['iss'] = 'https://stormpath.com'; $jwt['sub'] = self::$account->href; $jwt['aud'] = UUID::v4(); $jwt['exp'] = time() + 60; $jwt['iat'] = time(); $jwt['jti'] = UUID::v4(); $jwt['irt'] = UUID::v4(); $jwt['state'] = ""; $jwt['isNewSub'] = false; $jwt['status'] = "AUTHENTICATED"; $apiSecret = Client::getInstance()->getDataStore()->getApiKey()->getSecret(); $token = JWT::encode($jwt, $apiSecret); return 'https://stormpath.com?jwtResponse=' . $token; }