Пример #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Setting up default OAuth scopes...</info>');
     $oAuthService = new OAuthService($this->getSlim());
     foreach ($this->getSlim()->config('xAPI')['supported_auth_scopes'] as $authScope) {
         $scope = $oAuthService->addScope($authScope['name'], $authScope['description']);
     }
     $output->writeln('<info>OAuth scopes configured!</info>');
 }
Пример #2
0
 public function post()
 {
     $request = $this->getSlim()->request();
     // Do the validation - TODO!!!
     //$this->statementValidator->validateRequest($request);
     //$this->statementValidator->validatePutRequest($request);
     $this->oAuthService->accessTokenPost($request);
     // Authorization is always requested
     $view = new AccessTokenView(['service' => $this->oAuthService]);
     $view = $view->renderGet();
     Resource::jsonResponse(Resource::STATUS_OK, $view);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $oAuthService = new OAuthService($this->getSlim());
     $oAuthService->fetchClients();
     $textArray = [];
     foreach ($oAuthService->getCursor() as $document) {
         $textArray[] = $document->jsonSerialize();
     }
     $text = json_encode($textArray, JSON_PRETTY_PRINT);
     $output->writeln('<info>Clients successfully fetched!</info>');
     $output->writeln('<info>Info:</info>');
     $output->writeln($text);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $oAuthService = new OAuthService($this->getSlim());
     $helper = $this->getHelper('question');
     $question = new Question('Please enter a name (scope identifier): ', 'untitled');
     $name = $helper->ask($input, $output, $question);
     $question = new Question('Please enter a description: ', '');
     $description = $helper->ask($input, $output, $question);
     $scope = $oAuthService->addScope($name, $description);
     $text = json_encode($scope, JSON_PRETTY_PRINT);
     $output->writeln('<info>Auth scope successfully created!</info>');
     $output->writeln('<info>Info:</info>');
     $output->writeln($text);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $oAuthService = new OAuthService($this->getSlim());
     $helper = $this->getHelper('question');
     $question = new Question('Please enter a name: ', 'untitled');
     $name = $helper->ask($input, $output, $question);
     $question = new Question('Please enter a description: ', '');
     $description = $helper->ask($input, $output, $question);
     $question = new Question('Please enter a redirect URI: ');
     $redirectUri = $helper->ask($input, $output, $question);
     $client = $oAuthService->addClient($name, $description, $redirectUri);
     $text = json_encode($client, JSON_PRETTY_PRINT);
     $output->writeln('<info>OAuth client successfully created!</info>');
     $output->writeln('<info>Info:</info>');
     $output->writeln($text);
 }
Пример #6
0
 public function post()
 {
     $request = $this->getSlim()->request();
     // Do the validation - TODO!!!
     //$this->statementValidator->validateRequest($request);
     //$this->statementValidator->validatePutRequest($request);
     if ($this->userService->loggedIn()) {
         // Authorization is always requested
         $this->oAuthService->authorizePost($request);
         $redirectUri = $this->oAuthService->getRedirectUri();
         $this->getSlim()->response->headers->set('Location', $redirectUri);
         Resource::response(Resource::STATUS_FOUND);
     } else {
         // Unauthorized
         Resource::response(Resource::STATUS_UNAUTHORIZED);
     }
 }
Пример #7
0
         } catch (\InvalidArgumentException $e) {
             throw new \Exception('X-Experience-API-Version header invalid.', Resource::STATUS_BAD_REQUEST);
         }
     }
 });
 // Request logging
 $app->container->singleton('requestLog', function () use($app) {
     $logService = new LogService($app);
     $logDocument = $logService->logRequest($app->request);
     return $logDocument;
 });
 // Auth - token
 $app->container->singleton('auth', function () use($app) {
     if (!$app->request->isOptions() && !($app->request->getPathInfo() === '/about')) {
         $basicAuthService = new BasicAuthService($app);
         $oAuthService = new OAuthService($app);
         $token = null;
         try {
             $token = $oAuthService->extractToken($app->request);
             $app->requestLog->addRelation('oAuthToken', $token)->save();
         } catch (AuthFailureException $e) {
             // Ignore
         }
         try {
             $token = $basicAuthService->extractToken($app->request);
             $app->requestLog->addRelation('basicToken', $token)->save();
         } catch (AuthFailureException $e) {
             // Ignore
         }
         if (null === $token) {
             throw new \Exception('Credentials invalid!', Resource::STATUS_UNAUTHORIZED);