isRestController($resolver)) { return false; } /** @var SessionBuilder $builder */ foreach ($this->getSessionBuilders() as $builder) { if ($builder->isApplicable($request)) { return $this->startSession($builder->getSession($request)); } } throw new LoginFailedException(['Request cannot be authenticated.']); } /** * Start a session through SessionManager * * @param $session * @return bool */ protected function startSession($session) { return \common_session_SessionManager::startSession($session); } /** * Fetch rest session builder from the config * * @return SessionBuilder[] */ protected function getSessionBuilders() { $adapters = is_array($this->getOption(self::OPTION_BUILDERS)) ? $this->getOption(self::OPTION_BUILDERS) : []; foreach ($adapters as $key => $adapter) { if (!is_a($adapter, SessionBuilder::class, true)) { throw new \LogicException('Session adapter must implement interface "SessionBuilder".'); } $adapters[$key] = $this->propagate(new $adapter()); } return $adapters; } /** * Check if the requested controller is a RestController * * @param Resolver $resolver * * @return bool * @throws ResolverException * @throws common_exception_InconsistentData * @throws common_ext_ManifestNotFoundException */ protected function isRestController(Resolver $resolver): bool { return is_subclass_of($resolver->getControllerClass(), RestControllerInterface::class, true); } }