logLti($ltiLaunchData->getVariables()); /** @var LtiValidatorService $validator */ $validator = $this->getServiceLocator()->get(LtiValidatorService::SERVICE_ID); $validator->validateLaunchData($ltiLaunchData); LtiService::singleton()->startLtiSession($request); /** @var CookieVerifyService $cookieService */ $cookieService = $this->getServiceManager()->get(CookieVerifyService::SERVICE_ID); if ($cookieService->isVerifyCookieRequired()) { if (tao_models_classes_accessControl_AclProxy::hasAccess('verifyCookie', 'CookieUtils', 'taoLti')) { $cookieRedirect = _url( 'verifyCookie', 'CookieUtils', 'taoLti', [ 'session' => session_id(), 'redirect' => urlencode(_url('run', null, null, $_GET)), ] ); $this->redirect($cookieRedirect); } else { throw new LtiException( __('You are not authorized to use this system'), LtiErrorMessage::ERROR_UNAUTHORIZED ); } } else { $this->forward('run', null, null, $_GET); } } catch (common_user_auth_AuthFailedException $e) { $lockoutService = $this->getServiceLocator()->get(OauthService::SERVICE_ID) ->getSubService(OauthService::OPTION_LOCKOUT_SERVICE); $lockoutService->logFailedAttempt(); common_Logger::i($e->getMessage()); throw new LtiException( __('The LTI connection could not be established'), LtiErrorMessage::ERROR_UNAUTHORIZED ); } catch (LtiException $e) { common_Logger::i($e->__toString()); if (tao_helpers_Request::isAjax()) { throw new common_exception_IsAjaxAction(__CLASS__ . '::' . __FUNCTION__); } throw $e; } catch (tao_models_classes_oauth_Exception $e) { common_Logger::i($e->getMessage()); throw new LtiException( __('The LTI connection could not be established'), LtiErrorMessage::ERROR_UNAUTHORIZED ); } } /** * run() contains the actual tool's controller */ abstract public function run(); /** * Logging LTI launch params * @param $variables */ protected function logLti($variables) { foreach ($variables as $key => $value) { if (strpos($key, 'oauth_') === 0) { unset($variables[$key]); } } $this->logInfo('LTI_LAUNCH_PARAMS:' . json_encode($variables)); } protected function getValidatedLtiMessagePayload(): LtiMessagePayloadInterface { return $this->getServiceLocator() ->get(Lti1p3Validator::class) ->getValidatedPayload($this->getPsrRequest()); } }