/** * @param Request $request * @param string|null $redirectUri * @throws \Symfony\Component\Security\Core\Exception\AuthenticationException * @throws AppscoOAuthException * @return AppscoToken */ public function callback(Request $request, $redirectUri = null) { $code = $request->get('code'); $state = $request->get('state'); $this->validateState($state); $this->checkError($request); $accessData = $this->client->getAccessData($code, $redirectUri); $profile = $this->client->profileRead('me'); if (false == $profile) { throw new AuthenticationException('Unable to get profile info from Appsco'); } return $this->createToken($accessData, $profile); }
/** * @param Notification $notification * @throws InvalidNotificationException * @return void */ public function validate(Notification $notification) { $certificateList = $this->client->certificateGet($notification->getIssuer()); if (0 == count($certificateList->getCertificates())) { throw new InvalidNotificationException(sprintf("Issuer '%s' has no Appsco certificates", $notification->getIssuer())); } $error = null; foreach ($certificateList->getCertificates() as $certificate) { try { $this->jwtEncoder->verify($notification, $certificate->getCertificate()); $error = null; break; } catch (\Exception $ex) { $error = $ex; } } if ($error) { throw new InvalidNotificationException(sprintf("Unable to verify certificate of issuer '%s'", $notification->getIssuer()), 0, $error); } }