예제 #1
0
 /**
  * Returns an Response object containing the OPAuth data
  *
  * @return Response
  */
 public function getResponse()
 {
     if ($this->actionRequest instanceof \TYPO3\Flow\Mvc\ActionRequest && $this->actionRequest->hasArgument('opauth')) {
         $data = $this->actionRequest->getArgument('opauth');
         $response = unserialize(base64_decode($data));
         $this->response = new Response($response);
     }
     return $this->response;
 }
 /**
  * Maps arguments delivered by the request object to the local controller arguments.
  *
  * @return void
  * @throws \TYPO3\Flow\Mvc\Exception\RequiredArgumentMissingException
  * @api
  */
 protected function mapRequestArgumentsToControllerArguments()
 {
     foreach ($this->arguments as $argument) {
         $argumentName = $argument->getName();
         if ($this->request->hasArgument($argumentName)) {
             $argument->setValue($this->request->getArgument($argumentName));
         } elseif ($argument->isRequired()) {
             throw new \TYPO3\Flow\Mvc\Exception\RequiredArgumentMissingException('Required argument "' . $argumentName . '" is not set.', 1298012500);
         }
     }
 }
 /**
  * Updates the authentication credentials, the authentication manager needs to authenticate this token.
  * This could be a username/password from a login controller.
  * This method is called while initializing the security context. By returning TRUE you
  * make sure that the authentication manager will (re-)authenticate the tokens with the current credentials.
  * Note: You should not persist the credentials!
  *
  * @param ActionRequest $actionRequest The current request instance
  * @throws \InvalidArgumentException
  * @return boolean TRUE if this token needs to be (re-)authenticated
  */
 public function updateCredentials(ActionRequest $actionRequest)
 {
     if ($actionRequest->getHttpRequest()->getMethod() !== 'GET' || $actionRequest->getInternalArgument('__oauth2Provider') !== $this->authenticationProviderName) {
         return;
     }
     if (!$actionRequest->hasArgument('code')) {
         $this->setAuthenticationStatus(TokenInterface::WRONG_CREDENTIALS);
         $this->securityLogger->log('There was no argument `code` provided.', LOG_NOTICE);
         return;
     }
     $code = $actionRequest->getArgument('code');
     $redirectUri = $this->oauthUriBuilder->getRedirectionEndpointUri($this->authenticationProviderName);
     try {
         $this->credentials['accessToken'] = $this->tokenEndpoint->requestAuthorizationCodeGrantAccessToken($code, $redirectUri);
         $this->setAuthenticationStatus(TokenInterface::AUTHENTICATION_NEEDED);
     } catch (Exception $exception) {
         $this->setAuthenticationStatus(TokenInterface::WRONG_CREDENTIALS);
         $this->securityLogger->logException($exception);
         return;
     }
 }
 /**
  * @test
  */
 public function aSingleArgumentCanBeSetWithSetArgumentAndRetrievedWithGetArgument()
 {
     $this->actionRequest->setArgument('someArgumentName', 'theValue');
     $this->assertEquals('theValue', $this->actionRequest->getArgument('someArgumentName'));
 }
예제 #5
0
 /**
  * @test
  */
 public function aSingleArgumentCanBeSetWithSetArgumentAndRetrievedWithGetArgument()
 {
     $httpRequest = HttpRequest::create(new Uri('http://robertlemke.com/blog'));
     $actionRequest = new ActionRequest($httpRequest);
     $actionRequest->setArgument('someArgumentName', 'theValue');
     $this->assertEquals('theValue', $actionRequest->getArgument('someArgumentName'));
 }