/** * Overridden authenticateAction method to check for an existing account with the Opauth data. * * @return string */ public function authenticateAction() { $opauthResponse = $this->opauth->getResponse(); if ($this->authenticateActionAlreadyCalled == FALSE && $opauthResponse !== NULL) { $this->authenticateActionAlreadyCalled = TRUE; if ($opauthResponse->isAuthenticationSucceeded()) { $opauthAccount = $this->opauthAccountService->getAccount($opauthResponse); $doesAccountExists = $this->opauthAccountService->doesAccountExist($opauthAccount); if ($doesAccountExists === FALSE) { return $this->onOpauthAccountDoesNotExist($opauthResponse->getRawData(), $opauthAccount); } } else { return $this->onOpauthAuthenticationFailure($opauthResponse->getRawData()); } } return parent::authenticateAction(); }
/** * Tries to authenticate the given token. Sets isAuthenticated to TRUE if authentication succeeded. * * @param \TYPO3\Flow\Security\Authentication\TokenInterface $authenticationToken The token to be authenticated * @throws \TYPO3\Flow\Security\Exception\UnsupportedAuthenticationTokenException * @return void */ public function authenticate(\TYPO3\Flow\Security\Authentication\TokenInterface $authenticationToken) { if (!$authenticationToken instanceof OpauthToken) { throw new \TYPO3\Flow\Security\Exception\UnsupportedAuthenticationTokenException('This provider cannot authenticate the given token.', 1381598908); } $response = $this->opauth->getResponse(); if ($response !== NULL && $response->isAuthenticationSucceeded()) { $accountIdentifier = $this->accountService->createAccountIdentifier($response); $authenticationProviderName = $this->name; $account = $this->accountRepository->findByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, $authenticationProviderName); if ($account !== NULL) { $authenticationToken->setAccount($account); $authenticationToken->setAuthenticationStatus(\TYPO3\Flow\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL); } } else { $authenticationToken->setAuthenticationStatus(\TYPO3\Flow\Security\Authentication\TokenInterface::NO_CREDENTIALS_GIVEN); } }